Class: Workarea::Admin::ActivityViewModel
- Inherits:
-
ApplicationViewModel
- Object
- ApplicationViewModel
- Workarea::Admin::ActivityViewModel
- Defined in:
- app/view_models/workarea/admin/activity_view_model.rb
Instance Method Summary collapse
- #admin_options ⇒ Object
- #days ⇒ Object
- #entries ⇒ Object
- #hide_first_header? ⇒ Boolean
- #page ⇒ Object
- #type_options ⇒ Object
Instance Method Details
#admin_options ⇒ Object
16 17 18 19 |
# File 'app/view_models/workarea/admin/activity_view_model.rb', line 16 def [[t('workarea.admin.activities.filters.everyone'), nil]] + User.admins.map { |u| [u.name, u.id] } end |
#days ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/view_models/workarea/admin/activity_view_model.rb', line 21 def days @days ||= entries.reduce({}) do |memo, entry| day = entry.created_at.to_date memo[day] ||= [] memo[day] << entry memo end end |
#entries ⇒ Object
4 5 6 |
# File 'app/view_models/workarea/admin/activity_view_model.rb', line 4 def entries @entries ||= scoped_entries.page(page).per(per_page) end |
#hide_first_header? ⇒ Boolean
34 35 36 37 38 39 |
# File 'app/view_models/workarea/admin/activity_view_model.rb', line 34 def hide_first_header? return false if page == 1 previous_entry = scoped_entries.skip(entries.offset_value - 1).first previous_entry.created_at.to_date == entries.first.created_at.to_date end |
#page ⇒ Object
30 31 32 |
# File 'app/view_models/workarea/admin/activity_view_model.rb', line 30 def page ([:page].presence || 1).to_i end |
#type_options ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/view_models/workarea/admin/activity_view_model.rb', line 8 def [[t('workarea.admin.activities.filters.all_types'), nil]] + types.map do |type| name = ActiveModel::Naming.param_key(type.constantize) [name.titleize.downcase, type] end end |