Module: Decidim::Meetings::MeetingsHelper
- Includes:
- ApplicationHelper, LikeableHelper, ApplicationHelper, ResourceHelper, TranslationsHelper
- Defined in:
- app/helpers/decidim/meetings/meetings_helper.rb
Overview
Custom helpers used in meetings views
Instance Method Summary collapse
- #author_presenter_for(author) ⇒ Object
-
#calculate_start_and_end_time_of_agenda_items(agenda_items, meeting, start_time_parent = nil) ⇒ Object
Public: This method is used to calculate the start and end time of each agenda item passed.
-
#display_duration_agenda_items(agenda_item_id, index, agenda_items_times) ⇒ Object
Public: This method is used to build the html for show start and end time of each agenda item.
-
#google_calendar_event_url(meeting) ⇒ Object
Public: URL to create an event in Google Calendars based on meeting data.
-
#meeting_description(meeting, max_length = 120) ⇒ Object
Public: truncates the meeting description.
-
#meeting_type_badge_css_class(type) ⇒ Object
Public: The css class applied based on the meeting type to the css class.
-
#registration_code_help_text ⇒ Object
Public: Registration code generic help text.
- #render_schema_org_event_meeting(meeting) ⇒ Object
-
#validation_state_for(registration) ⇒ Object
Public: Registration validation state as text.
- #waitlist_status_block(registration) ⇒ Object
Methods included from ApplicationHelper
#activity_filter_values, #apply_meetings_pack_tags, #filter_date_values, #filter_origin_values, #filter_sections, #filter_type_values, #iframe_embed_or_live_event_page?, #online_or_hybrid_meeting?, #prevent_timeout_seconds, #render_meeting_body, #render_meeting_sanitize_field, #safe_content?, #safe_content_admin?
Instance Method Details
#author_presenter_for(author) ⇒ Object
126 127 128 129 130 131 132 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 126 def () if .is_a?(Decidim::Organization) Decidim::Meetings::OfficialAuthorPresenter.new else present() end end |
#calculate_start_and_end_time_of_agenda_items(agenda_items, meeting, start_time_parent = nil) ⇒ Object
Public: This method is used to calculate the start and end time
of each agenda item passed
agenda_items - an Active record of agenda items meeting - the meeting of the agenda, to know the start and end time start_time_parent - used to pass the start time of parent agenda item
Returns an Array.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 62 def calculate_start_and_end_time_of_agenda_items(agenda_items, meeting, start_time_parent = nil) array = [] agenda_items.each_with_index do |agenda_item, index| hash = { agenda_item_id: agenda_item.id, start_time: nil, end_time: nil } if index.zero? start = if agenda_item.parent? meeting.start_time else start_time_parent end hash[:start_time] = start else hash[:start_time] = array[index - 1][:end_time] end hash[:end_time] = hash[:start_time] + agenda_item.duration.minutes array.push(hash) end array end |
#display_duration_agenda_items(agenda_item_id, index, agenda_items_times) ⇒ Object
Public: This method is used to build the html for show start and end time of each agenda item
agenda_item_id - an id of agenda item agenda_items_times - is a hash with the two times
Returns an HMTL.
98 99 100 101 102 103 104 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 98 def display_duration_agenda_items(agenda_item_id, index, agenda_items_times) html = "" if agenda_item_id == agenda_items_times[index][:agenda_item_id] html += "[#{agenda_items_times[index][:start_time].strftime("%H:%M")} - #{agenda_items_times[index][:end_time].strftime("%H:%M")}]" end html.html_safe end |
#google_calendar_event_url(meeting) ⇒ Object
Public: URL to create an event in Google Calendars based on meeting data.
meeting - a Decidim::Meeting instance.
Returns a String.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 140 def google_calendar_event_url(meeting) meeting_url = resource_locator(meeting).url meeting = present(meeting) params = { text: meeting.title, dates: meeting.dates_param, details: I18n.t( "decidim.meetings.meetings.calendar_modal.full_details_html", link: link_to(meeting_url, meeting_url) ) } base_url = "https://calendar.google.com/calendar/u/0/r/eventedit" "#{base_url}?#{params.to_param}" end |
#meeting_description(meeting, max_length = 120) ⇒ Object
Public: truncates the meeting description
meeting - a Decidim::Meeting instance max_length - a number to limit the length of the description
Returns the meeting’s description truncated.
19 20 21 22 23 24 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 19 def meeting_description(meeting, max_length = 120) link = resource_locator(meeting).path description = CGI.unescapeHTML present(meeting).description tail = "... #{link_to(t("read_more", scope: "decidim.meetings"), link)}".html_safe CGI.unescapeHTML html_truncate(description, max_length:, tail:) end |
#meeting_type_badge_css_class(type) ⇒ Object
Public: The css class applied based on the meeting type to
the css class.
type - The String type of the meeting.
Returns a String.
45 46 47 48 49 50 51 52 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 45 def meeting_type_badge_css_class(type) case type when "withdraw" "alert" when "private", "transparent" "reverse" end end |
#registration_code_help_text ⇒ Object
Public: Registration code generic help text.
Returns a String.
109 110 111 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 109 def registration_code_help_text t("registration_code_help_text", scope: "decidim.meetings.meetings.show") end |
#render_schema_org_event_meeting(meeting) ⇒ Object
155 156 157 158 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 155 def render_schema_org_event_meeting(meeting) exported_meeting = Decidim::Exporters::JSON.new([meeting], Decidim::Meetings::SchemaOrgEventMeetingSerializer).export.read JSON.pretty_generate(JSON.parse(exported_meeting).first) end |
#validation_state_for(registration) ⇒ Object
Public: Registration validation state as text.
registration - The registration that holds the validation code.
Returns a String.
118 119 120 121 122 123 124 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 118 def validation_state_for(registration) if registration.validated? t("validated", scope: "decidim.meetings.meetings.show.registration_state") else t("validation_pending", scope: "decidim.meetings.meetings.show.registration_state") end end |
#waitlist_status_block(registration) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 26 def waitlist_status_block(registration) return unless registration.waiting_list? render layout: "decidim/meetings/layouts/aside_block", locals: { emoji: "ticket-line" } do content_tag(:div) do safe_join([ content_tag(:h3, t("waitlist.status", scope: "decidim.meetings.meetings.show"), class: "meeting__aside-block__title"), content_tag(:p, t("waitlist.description", scope: "decidim.meetings.meetings.show"), class: "text-sm") ]) end end end |