Class: Decidim::Meetings::MeetingMonthCell
- Inherits:
-
ViewModel
- Object
- Cell::ViewModel
- ViewModel
- Decidim::Meetings::MeetingMonthCell
show all
- Defined in:
- decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb
Constant Summary
AmendmentsHelper::TOTAL_STEPS
Instance Method Summary
collapse
Methods inherited from ViewModel
#call, #current_user, #view_context
Methods included from IconHelper
#component_icon, #manifest_icon, #resource_icon, #resource_type_icon, #resource_type_icon_key, #text_with_resource_icon
#_icon_classes, #apple_favicon, #application_path, #current_url, #current_user_unread_data, #extended_navigation_bar, #external_icon, #favicon, #icon, #legacy_favicon, #role
#with_tooltip
#decidim_drawer, #decidim_modal
#current_organization_name, #organization_colors, #organization_description_label, #organization_name
#default_locale?
#add_body_classes, #cell, #edit_link, #extra_admin_link, #html_truncate, #present, #prevent_timeout_seconds, #resolve_presenter_class, #text_initials
#cache
#accept_and_reject_buttons_for, #action_button_card_for, #allowed_to_accept_and_reject?, #allowed_to_promote?, #amendments_enabled?, #amendments_form_field_for, #amendments_form_fields_label, #amendments_form_fields_value, #can_participate_in_private_space?, #can_react_to_emendation?, #current_step, #emendation_actions_for, #emendation_announcement_for, #promote_button_for, #render_emendation_body, #total_steps, #wizard_aside_back_url, #wizard_header_title
included, #text_editor_for
#floating_help
#has_visible_scopes?, #scope_name_for_picker, #scopes_picker_field, #scopes_picker_filter, #scopes_select_field, #scopes_select_tag
#areas_for_select, #base_error_messages, #decidim_form_for, #decidim_form_slug_url, #editor_field_tag, #form_field_has_error?, #form_required_explanation, #name_with_locale, #ordered_scopes_descendants, #ordered_scopes_descendants_for_select, #scopes_picker_field_tag, #tab_element_class_for, #translated_field_tag
#normalize_provider_name, #oauth_icon, #provider_name
#decidim_escape_translated, #decidim_html_escape, #decidim_rich_text, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_sanitize_translated, #decidim_url_escape, included
#element_id
#button_to, #submit_tag
#action_authorized_button_to, #action_authorized_link_to, #logged_button_to, #logged_link_to
#linked_classes_filter_values_for, #linked_classes_for, #resource_locator
Instance Method Details
#abbr_day_names ⇒ Object
32
33
34
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 32
def abbr_day_names
@abbr_day_names ||= I18n.t("date.abbr_day_names").rotate(first_week_date_rotation)
end
|
#beginning_of_week ⇒ Object
51
52
53
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 51
def beginning_of_week
@beginning_of_week ||= options[:beginning_of_week] || Date.beginning_of_week
end
|
#day_class(date) ⇒ Object
44
45
46
47
48
49
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 44
def day_class(date)
return "is-today" if date == Date.current
return if events.exclude?(date)
"is-#{date < Date.current ? "past" : "upcoming"}-event"
end
|
#day_names ⇒ Object
36
37
38
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 36
def day_names
@day_names ||= I18n.t("date.day_names").rotate(first_week_date_rotation)
end
|
#events ⇒ Object
59
60
61
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 59
def events
options[:events] || meetings.select { |meeting| meeting.start_time.month == month }.map { |meeting| meeting.start_time.to_date }
end
|
#first_day_of_month?(date) ⇒ Boolean
40
41
42
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 40
def first_day_of_month?(date)
date.day == 1
end
|
#first_meeting ⇒ Object
63
64
65
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 63
def first_meeting
@first_meeting ||= meetings.first
end
|
#first_week_date_rotation ⇒ Object
67
68
69
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 67
def first_week_date_rotation
@first_week_date_rotation ||= Date::DAYS_INTO_WEEK[beginning_of_week.to_sym].to_i
end
|
#meetings_in_this_month? ⇒ Boolean
14
15
16
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 14
def meetings_in_this_month?
meetings.collect(&:start_time).map { |date| date.strftime("%m").to_i }.any? month
end
|
#month_days ⇒ Object
18
19
20
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 18
def month_days
start_date.to_date.all_month
end
|
#month_name ⇒ Object
28
29
30
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 28
def month_name
@month_name ||= I18n.t("date.month_names")[month]
end
|
#show ⇒ Object
10
11
12
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 10
def show
render if meetings_in_this_month?
end
|
#start_date ⇒ Object
55
56
57
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 55
def start_date
options[:start_date] || first_meeting.start_time
end
|
#weeks ⇒ Object
22
23
24
25
26
|
# File 'decidim-meetings/app/cells/decidim/meetings/meeting_month_cell.rb', line 22
def weeks
month_days.group_by do |day|
(1 - first_week_date_rotation).days.since(day).cweek
end.values
end
|