Module: Decidim::Meetings::MeetingsHelper

Includes:
ApplicationHelper, EndorsableHelper, ApplicationHelper, ResourceHelper, TranslationsHelper
Included in:
Directory::ApplicationHelper, MeetingCellsHelper, PublicParticipantsListCell
Defined in:
decidim-meetings/app/helpers/decidim/meetings/meetings_helper.rb

Overview

Custom helpers used in meetings views

Constant Summary

Constants included from AmendmentsHelper

AmendmentsHelper::TOTAL_STEPS

Instance Method Summary collapse

Methods included from EndorsableHelper

#current_user_can_endorse?, #endorsement_buttons_cell, #endorsements_blocked?, #endorsements_enabled?, #endorsers_list_cell, #fully_endorsed?, #path_to_create_endorsement, #path_to_destroy_endorsement, #render_endorsement_identity, #show_endorsements_card?

Methods included from ResourceHelper

#linked_classes_filter_values_for, #linked_classes_for, #resource_locator, #resource_title

Methods included from TranslationsHelper

empty_translatable, ensure_translatable, multi_translation, translated_in_current_locale?

Methods included from TranslatableAttributes

#default_locale?

Methods included from ApplicationHelper

#activity_filter_values, #apply_meetings_pack_tags, #filter_date_values, #filter_origin_values, #filter_type_values, #iframe_embed_or_live_event_page?, #online_or_hybrid_meeting?, #prevent_timeout_seconds, #render_meeting_body, #safe_content?, #safe_content_admin?

Methods included from FollowableHelper

#follow_button_for

Methods included from RichTextEditorHelper

included, #text_editor_for

Methods included from CheckBoxesTreeHelper

#check_boxes_tree_options, #filter_areas_values, #filter_categories_values, #filter_global_scopes_values, #filter_origin_values, #filter_scopes_values, #filter_text_for, #filter_tree_from_array, #flat_filter_values, #resource_filter_scope_values

Methods included from SanitizeHelper

#decidim_html_escape, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_url_escape, included

Methods included from Comments::CommentsHelper

#comments_for, #inline_comments_for

Methods included from MapHelper

#meetings_data_for_map

Methods included from Decidim::MapHelper

#dynamic_map_for, #static_map_link

Methods included from PaginateHelper

#decidim_paginate, #per_page

Methods included from ApplicationHelper

#cell, #edit_link, #extra_admin_link, #html_truncate, #present, #prevent_timeout_seconds, #resolve_presenter_class, #step_cta_url

Methods included from CacheHelper

#cache

Methods included from AmendmentsHelper

#accept_and_reject_buttons_for, #action_button_card_for, #allowed_to_accept_and_reject?, #allowed_to_promote?, #amend_button_for, #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

Methods included from ContextualHelpHelper

#floating_help

Methods included from ScopesHelper

#has_visible_scopes?, #scope_name_for_picker, #scopes_picker_field, #scopes_picker_filter, #scopes_select_field, #scopes_select_tag

Methods included from DecidimFormHelper

#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

Methods included from OmniauthHelper

#normalize_provider_name, #oauth_icon, #provider_name

Instance Method Details

#author_presenter_for(author) ⇒ Object



113
114
115
116
117
118
119
# File 'decidim-meetings/app/helpers/decidim/meetings/meetings_helper.rb', line 113

def author_presenter_for(author)
  if author.is_a?(Decidim::Organization)
    Decidim::Meetings::OfficialAuthorPresenter.new
  else
    present(author)
  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.



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
75
76
# File 'decidim-meetings/app/helpers/decidim/meetings/meetings_helper.rb', line 49

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

#current_user_groups?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'decidim-meetings/app/helpers/decidim/meetings/meetings_helper.rb', line 121

def current_user_groups?
  current_organization.user_groups_enabled? && Decidim::UserGroups::ManageableUserGroups.for(current_user).verified.any?
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.



85
86
87
88
89
90
91
# File 'decidim-meetings/app/helpers/decidim/meetings/meetings_helper.rb', line 85

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.



131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'decidim-meetings/app/helpers/decidim/meetings/meetings_helper.rb', line 131

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 'decidim-meetings/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.



32
33
34
35
36
37
38
39
# File 'decidim-meetings/app/helpers/decidim/meetings/meetings_helper.rb', line 32

def meeting_type_badge_css_class(type)
  case type
  when "withdraw"
    "alert"
  when "private", "transparent"
    "reverse"
  end
end

#registration_code_help_textObject

Public: Registration code generic help text.

Returns a String.



96
97
98
# File 'decidim-meetings/app/helpers/decidim/meetings/meetings_helper.rb', line 96

def registration_code_help_text
  t("registration_code_help_text", scope: "decidim.meetings.meetings.show")
end

#validation_state_for(registration) ⇒ Object

Public: Registration validation state as text.

registration - The registration that holds the validation code.

Returns a String.



105
106
107
108
109
110
111
# File 'decidim-meetings/app/helpers/decidim/meetings/meetings_helper.rb', line 105

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