Module: Pageflow::Admin::EntriesHelper

Defined in:
app/helpers/pageflow/admin/entries_helper.rb

Overview

rubocop:todo Style/Documentation

Since:

  • 12.2

Instance Method Summary collapse

Instance Method Details

#admin_entry_title(entry) ⇒ Object

Since:

  • 12.2



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_statesObject

Since:

  • 12.2



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_summariesObject

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.

Since:

  • 12.2



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

Since:

  • 12.2



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?

  (:span,
              class: 'entry_comments_indicator',
              data: {tooltip: entry_comments_tooltip(summary)}) do
    safe_join([summary.topic_count.to_s,
               ((:span, '', class: 'unread_dot') if summary.unread?)].compact)
  end
end

#entry_comments_tooltip(summary) ⇒ Object

Since:

  • 12.2



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

Since:

  • 12.2



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