module Decidim::Meetings::MeetingsHelper
def author_presenter_for(author)
def author_presenter_for(author) if author.is_a?(Decidim::Organization) Decidim::Meetings::OfficialAuthorPresenter.new else present(author) end end
def calculate_start_and_end_time_of_agenda_items(agenda_items, meeting, start_time_parent = nil)
start_time_parent - used to pass the start time of parent agenda item
meeting - the meeting of the agenda, to know the start and end time
agenda_items - an Active record of agenda items
of each agenda item passed
Public: This method is used to calculate the start and end time
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
def current_user_groups?
def current_user_groups? current_organization.user_groups_enabled? && Decidim::UserGroups::ManageableUserGroups.for(current_user).verified.any? end
def display_duration_agenda_items(agenda_item_id, index, agenda_items_times)
agenda_items_times - is a hash with the two times
agenda_item_id - an id of agenda item
and end time of each agenda item
Public: This method is used to build the html for show start
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
def google_calendar_event_url(meeting)
meeting - a Decidim::Meeting instance.
data.
Public: URL to create an event in Google Calendars based on meeting
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
def meeting_description(meeting, max_length = 120)
max_length - a number to limit the length of the description
meeting - a Decidim::Meeting instance
Public: truncates the meeting description
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
def meeting_type_badge_css_class(type)
type - The String type of the meeting.
the css class.
Public: The css class applied based on the meeting type to
def meeting_type_badge_css_class(type) case type when "withdraw" "alert" when "private", "transparent" "reverse" end end
def registration_code_help_text
Public: Registration code generic help text.
def registration_code_help_text t("registration_code_help_text", scope: "decidim.meetings.meetings.show") end
def validation_state_for(registration)
registration - The registration that holds the validation code.
Public: Registration validation state as text.
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