Module: Decidim::Meetings::ApplicationHelper
- Includes:
- CheckBoxesTreeHelper, Comments::CommentsHelper, Decidim::MapHelper, MapHelper, RichTextEditorHelper, SanitizeHelper, PaginateHelper
- Included in:
- MeetingsHelper, PublicParticipantsListCell
- 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.
- #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.
-
#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’s 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.
52 53 54 55 56 57 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 52 def activity_filter_values [ ["all", t("decidim.meetings.meetings.filters.all")], ["my_meetings", t("decidim.meetings.meetings.filters.my_meetings")] ] end |
#filter_date_values ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 43 def filter_date_values [ ["all", t("decidim.meetings.meetings.filters.date_values.all")], ["upcoming", t("decidim.meetings.meetings.filters.date_values.upcoming")], ["past", t("decidim.meetings.meetings.filters.date_values.past")] ] end |
#filter_origin_values ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 16 def filter_origin_values origin_values = [] origin_values << TreePoint.new("official", t("decidim.meetings.meetings.filters.origin_values.official")) origin_values << TreePoint.new("participants", t("decidim.meetings.meetings.filters.origin_values.participants")) # todo if current_organization.user_groups_enabled? origin_values << TreePoint.new("user_group", t("decidim.meetings.meetings.filters.origin_values.user_groups")) # todo end # if current_organization.user_groups_enabled? and component_settings enabled enabled TreeNode.new( TreePoint.new("", t("decidim.meetings.meetings.filters.origin_values.all")), origin_values ) end |
#filter_type_values ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 31 def filter_type_values type_values = [] Decidim::Meetings::Meeting::TYPE_OF_MEETING.each do |type| type_values << TreePoint.new(type, t("decidim.meetings.meetings.filters.type_values.#{type}")) end TreeNode.new( TreePoint.new("", t("decidim.meetings.meetings.filters.type_values.all")), type_values ) end |
#iframe_embed_or_live_event_page?(meeting) ⇒ Boolean
96 97 98 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 96 def (meeting) %w(embed_in_meeting_page open_in_live_event_page).include? meeting. end |
#online_or_hybrid_meeting?(meeting) ⇒ Boolean
92 93 94 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 92 def online_or_hybrid_meeting?(meeting) meeting.online_meeting? || meeting.hybrid_meeting? end |
#prevent_timeout_seconds ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 82 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.
73 74 75 76 77 78 79 80 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 73 def render_meeting_body(meeting) sanitized = render_sanitized_content(meeting, :description) 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’s unless the meeting comes from a collaborative_draft or a participatory_text.
62 63 64 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 62 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.
68 69 70 |
# File 'app/helpers/decidim/meetings/application_helper.rb', line 68 def safe_content_admin? @meeting.official? end |