Module: Decidim::Meetings::MeetingsHelper
- Includes:
- ApplicationHelper, ResourceHelper, TranslationsHelper
- Included in:
- ApplicationHelper, MeetingCellsHelper
- Defined in:
- app/helpers/decidim/meetings/meetings_helper.rb
Overview
Custom helpers used in meetings views
Instance Method Summary collapse
-
#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.
-
#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.
Instance Method Details
#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.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 47 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.
83 84 85 86 87 88 89 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 83 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 |
#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.
17 18 19 20 21 22 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 17 def meeting_description(meeting, max_length = 120) link = resource_locator(meeting).path description = translated_attribute(meeting.description) tail = "... #{link_to(t("read_more", scope: "decidim.meetings"), link)}".html_safe CGI.unescapeHTML html_truncate(description, max_length: max_length, tail: 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.
30 31 32 33 34 35 36 37 |
# File 'app/helpers/decidim/meetings/meetings_helper.rb', line 30 def meeting_type_badge_css_class(type) case type when "private" "alert" when "transparent" "secondary" end end |