Module: Decidim::Meetings::ApplicationHelper
- Includes:
- CheckBoxesTreeHelper, Comments::CommentsHelper, FollowableHelper, Decidim::MapHelper, RichTextEditorHelper, SanitizeHelper, PaginateHelper
- Defined in:
- app/helpers/decidim/meetings/application_helper.rb
Overview
Custom helpers, scoped to the meetings engine.
Instance Method Summary collapse
-
#activity_filter_values ⇒ Object
Options to filter meetings by activity.
- #apply_meetings_pack_tags ⇒ Object
- #filter_date_values ⇒ Object
- #filter_origin_values ⇒ Object
-
#filter_sections(date: false, type: false, origin: false, taxonomies: false, space_type: false, activity: false) ⇒ Object
rubocop:disable Metrics/ParameterLists rubocop:disable Metrics/CyclomaticComplexity.
- #filter_type_values ⇒ Object
- #iframe_embed_or_live_event_page?(meeting) ⇒ Boolean
- #online_or_hybrid_meeting?(meeting) ⇒ Boolean
- #prevent_timeout_seconds ⇒ Object
-
#render_meeting_body(meeting) ⇒ Object
If the content is safe, HTML tags are sanitized, otherwise, they are stripped.
- #render_meeting_sanitize_field(meeting, field) ⇒ Object
-
#safe_content? ⇒ Boolean
If the meeting is official or the rich text editor is enabled on the frontend, the meeting body is considered as safe content; that is unless the meeting comes from a participatory_text.
-
#safe_content_admin? ⇒ Boolean
For admin entered content, the meeting body can contain certain extra tags, such as iframes.
Instance Method Details
#activity_filter_values ⇒ Object
Options to filter meetings by activity.
100 101 102 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 100 def activity_filter_values flat_filter_values(:all, :my_meetings, scope: "decidim.meetings.meetings.filters") end |
#apply_meetings_pack_tags ⇒ Object
149 150 151 152 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 149 def append_stylesheet_pack_tag("decidim_meetings", media: "all") append_javascript_pack_tag("decidim_meetings") end |
#filter_date_values ⇒ Object
36 37 38 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 36 def filter_date_values flat_filter_values(:all, :upcoming, :past, scope: "decidim.meetings.meetings.filters.date_values") end |
#filter_origin_values ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 16 def filter_origin_values origin_keys = %w(official participants) origin_values = flat_filter_values(*origin_keys, scope: "decidim.meetings.meetings.filters.origin_values") origin_values.prepend(["", t("all", scope: "decidim.meetings.meetings.filters.origin_values")]) filter_tree_from_array(origin_values) end |
#filter_sections(date: false, type: false, origin: false, taxonomies: false, space_type: false, activity: false) ⇒ Object
rubocop:disable Metrics/ParameterLists rubocop:disable Metrics/CyclomaticComplexity
42 43 44 45 46 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 42 def filter_sections(date: false, type: false, origin: false, taxonomies: false, space_type: false, activity: false) @filter_sections ||= begin items = [] if date items.append(method: :with_any_date, name: "[with_any_date]", collection: filter_date_values, label: t("decidim.meetings.meetings.filters.date"), id: "date", type: :radio_buttons) end if type items.append(method: :with_any_type, name: "[with_any_type]", collection: filter_type_values, label: t("decidim.meetings.meetings.filters.type"), id: "type") end if taxonomies available_taxonomy_filters.each do |taxonomy_filter| items.append(method: :with_any_taxonomies, name: "[with_any_taxonomies][#{taxonomy_filter.root_taxonomy_id}]", collection: filter_taxonomy_values_for(taxonomy_filter), label: decidim_sanitize_translated(taxonomy_filter.name), id: "taxonomy-#{taxonomy_filter.root_taxonomy_id}") end end if origin items.append(method: :with_any_origin, name: "[with_any_origin]", collection: filter_origin_values, label: t("decidim.meetings.meetings.filters.origin"), id: "origin") end if space_type items.append(method: :with_any_space, name: "[with_any_space]", collection: directory_meeting_spaces_values, label: t("decidim.meetings.directory.meetings.index.space_type"), id: "space_type") end if activity items.append(method: :activity, name: "[activity]", collection: activity_filter_values, label: t("decidim.meetings.meetings.filters.activity"), id: "activity", type: :radio_buttons) end items.reject { |item| item[:collection].blank? } end end |
#filter_type_values ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 25 def filter_type_values type_values = flat_filter_values(*Decidim::Meetings::Meeting::TYPE_OF_MEETING.keys, scope: "decidim.meetings.meetings.filters.type_values").map do |args| TreePoint.new(*args) end TreeNode.new( TreePoint.new("", t("decidim.meetings.meetings.filters.type_values.all")), type_values ) end |
#iframe_embed_or_live_event_page?(meeting) ⇒ Boolean
145 146 147 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 145 def (meeting) %w(embed_in_meeting_page open_in_live_event_page).include? meeting. end |
#online_or_hybrid_meeting?(meeting) ⇒ Boolean
141 142 143 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 141 def online_or_hybrid_meeting?(meeting) meeting.online? || meeting.hybrid? end |
#prevent_timeout_seconds ⇒ Object
131 132 133 134 135 136 137 138 139 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 131 def prevent_timeout_seconds return 0 unless respond_to?(:meeting) return 0 if !current_user || !meeting || !meeting.live? return 0 unless online_or_hybrid_meeting?(meeting) return 0 unless (meeting) return 0 unless meeting.iframe_access_level_allowed_for_user?(current_user) (meeting.end_time - Time.current).to_i end |
#render_meeting_body(meeting) ⇒ Object
If the content is safe, HTML tags are sanitized, otherwise, they are stripped.
118 119 120 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 118 def render_meeting_body(meeting) render_meeting_sanitize_field(meeting, :description) end |
#render_meeting_sanitize_field(meeting, field) ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 122 def render_meeting_sanitize_field(meeting, field) sanitized = render_sanitized_content(meeting, field) if safe_content? Decidim::ContentProcessor.render_without_format(sanitized).html_safe else Decidim::ContentProcessor.render(sanitized, "div") end end |
#safe_content? ⇒ Boolean
If the meeting is official or the rich text editor is enabled on the frontend, the meeting body is considered as safe content; that is unless the meeting comes from a participatory_text.
107 108 109 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 107 def safe_content? rich_text_editor_in_public_views? || safe_content_admin? end |
#safe_content_admin? ⇒ Boolean
For admin entered content, the meeting body can contain certain extra tags, such as iframes.
113 114 115 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 113 def safe_content_admin? @meeting.official? end |