Module: Pageflow::Admin::EntriesHelper
- Defined in:
- app/helpers/pageflow/admin/entries_helper.rb
Overview
rubocop:todo Style/Documentation
Instance Method Summary collapse
- #admin_entry_title(entry) ⇒ Object
- #collection_for_entry_publication_states ⇒ Object
-
#entry_comment_summaries ⇒ Object
Built for the whole page at once, so that rendering a row does not query.
- #entry_comments_indicator(entry, summaries: entry_comment_summaries) ⇒ Object
- #entry_comments_tooltip(summary) ⇒ Object
- #entry_type_collection(entry_types = Pageflow.config.entry_types) ⇒ Object
Instance Method Details
#admin_entry_title(entry) ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/helpers/pageflow/admin/entries_helper.rb', line 4 def admin_entry_title(entry) if entry.title.blank? I18n.t('pageflow.admin.entries.default_title', id: entry.id) else entry.title end end |
#collection_for_entry_publication_states ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/pageflow/admin/entries_helper.rb', line 12 def collection_for_entry_publication_states [ 'published_without_password_protection', 'published_with_password_protection', 'not_published' ].index_by do |state| I18n.t(state, scope: 'activerecord.values.pageflow/entry.publication_states') end end |
#entry_comment_summaries ⇒ Object
Built for the whole page at once, so that rendering a row does not query. Views without an index table collection pass their own summaries instead.
37 38 39 40 |
# File 'app/helpers/pageflow/admin/entries_helper.rb', line 37 def entry_comment_summaries @entry_comment_summaries ||= EntryCommentSummary.for_entries(collection, user: current_user) end |
#entry_comments_indicator(entry, summaries: entry_comment_summaries) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/pageflow/admin/entries_helper.rb', line 22 def entry_comments_indicator(entry, summaries: entry_comment_summaries) summary = summaries[entry.id] return unless summary&.any? content_tag(:span, class: 'entry_comments_indicator', data: {tooltip: entry_comments_tooltip(summary)}) do safe_join([summary.topic_count.to_s, (content_tag(:span, '', class: 'unread_dot') if summary.unread?)].compact) end end |
#entry_comments_tooltip(summary) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/pageflow/admin/entries_helper.rb', line 42 def entry_comments_tooltip(summary) scope = 'pageflow.admin.entries.comments' parts = [t("#{scope}.topic_count", count: summary.topic_count)] if summary.unread_topic_count.positive? parts << t("#{scope}.unread_topic_count", count: summary.unread_topic_count) end if summary.unread_reply_count.positive? parts << t("#{scope}.unread_reply_count", count: summary.unread_reply_count) end if summary.unread_resolution_count.positive? parts << t("#{scope}.unread_resolution_count", count: summary.unread_resolution_count) end t("#{scope}.tooltip", summary: parts.join(', ')) end |
#entry_type_collection(entry_types = Pageflow.config.entry_types) ⇒ Object
62 63 64 65 66 |
# File 'app/helpers/pageflow/admin/entries_helper.rb', line 62 def entry_type_collection(entry_types = Pageflow.config.entry_types) entry_types.map(&:name).index_by do |type| I18n.t(type, scope: 'activerecord.values.pageflow/entry.type_names') end end |