Module: Decidim::Meetings::ApplicationHelper
- Includes:
- CheckBoxesTreeHelper, Comments::CommentsHelper, FollowableHelper, Decidim::MapHelper, 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_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 collaborative_draft or a participatory_text.
-
#safe_content_admin? ⇒ Boolean
For admin entered content, the meeting body can contain certain extra tags, such as iframes.
Methods included from MapHelper
Instance Method Details
#activity_filter_values ⇒ Object
Options to filter meetings by activity.
43 44 45 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 43 def activity_filter_values flat_filter_values(:all, :my_meetings, scope: "decidim.meetings.meetings.filters") end |
#apply_meetings_pack_tags ⇒ Object
92 93 94 95 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 92 def append_stylesheet_pack_tag("decidim_meetings", media: "all") append_javascript_pack_tag("decidim_meetings") end |
#filter_date_values ⇒ Object
38 39 40 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 38 def filter_date_values flat_filter_values(:all, :upcoming, :past, scope: "decidim.meetings.meetings.filters.date_values") end |
#filter_origin_values ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 17 def filter_origin_values origin_keys = %w(official participants) origin_keys << "user_group" if current_organization.user_groups_enabled? 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_type_values ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 27 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
88 89 90 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 88 def (meeting) %w(embed_in_meeting_page open_in_live_event_page).include? meeting. end |
#online_or_hybrid_meeting?(meeting) ⇒ Boolean
84 85 86 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 84 def online_or_hybrid_meeting?(meeting) meeting.online? || meeting.hybrid? end |
#prevent_timeout_seconds ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 74 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.
61 62 63 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 61 def render_meeting_body(meeting) render_meeting_sanitize_field(meeting, :description) end |
#render_meeting_sanitize_field(meeting, field) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 65 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 collaborative_draft or a participatory_text.
50 51 52 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 50 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.
56 57 58 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 56 def safe_content_admin? @meeting.official? end |