Module: Admin::CalendarsHelper

Defined in:
app/helpers/admin/calendars_helper.rb

Instance Method Summary collapse

Instance Method Details

#calendar_months_count(year) ⇒ Object



26
27
28
29
# File 'app/helpers/admin/calendars_helper.rb', line 26

def calendar_months_count(year)
  calendar_counts.filter { |e| e[:year] == year }
                 .map { |e| [e[:month], e[:count]] }
end

#calendar_page_options(locale) ⇒ Object



11
12
13
14
15
16
17
# File 'app/helpers/admin/calendars_helper.rb', line 11

def calendar_page_options(locale)
  options_for_select(
    calendar_pages(locale).map do |p|
      [page_name(p, include_parents: true).gsub("»", "ยป"), p.id]
    end
  )
end

#calendar_pages(locale) ⇒ Object



5
6
7
8
9
# File 'app/helpers/admin/calendars_helper.rb', line 5

def calendar_pages(locale)
  Page.where(
    id: Page.with_dates.visible.pluck(:parent_page_id).uniq.compact
  ).in_locale(locale)
end

#calendar_years_with_countObject



19
20
21
22
23
24
# File 'app/helpers/admin/calendars_helper.rb', line 19

def calendar_years_with_count
  calendar_counts.each_with_object({}) do |entry, obj|
    obj[entry[:year]] ||= 0
    obj[entry[:year]] += entry[:count]
  end
end