Module: Decidim::Meetings::ApplicationHelper

Overview

Custom helpers, scoped to the meetings engine.

Instance Method Summary collapse

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_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

Instance Method Details

#activity_filter_valuesObject

Options to filter meetings by activity.



43
44
45
# File 'decidim-meetings/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_tagsObject



88
89
90
91
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 88

def apply_meetings_pack_tags
  append_stylesheet_pack_tag("decidim_meetings", media: "all")
  append_javascript_pack_tag("decidim_meetings")
end

#filter_date_valuesObject



38
39
40
# File 'decidim-meetings/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_valuesObject



17
18
19
20
21
22
23
24
25
# File 'decidim-meetings/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_valuesObject



27
28
29
30
31
32
33
34
35
36
# File 'decidim-meetings/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

Returns:

  • (Boolean)


84
85
86
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 84

def iframe_embed_or_live_event_page?(meeting)
  %w(embed_in_meeting_page open_in_live_event_page).include? meeting.iframe_embed_type
end

#online_or_hybrid_meeting?(meeting) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 80

def online_or_hybrid_meeting?(meeting)
  meeting.online? || meeting.hybrid?
end

#prevent_timeout_secondsObject



70
71
72
73
74
75
76
77
78
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 70

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 iframe_embed_or_live_event_page?(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
64
65
66
67
68
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 61

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 is unless the meeting comes from a collaborative_draft or a participatory_text.

Returns:

  • (Boolean)


50
51
52
# File 'decidim-meetings/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.

Returns:

  • (Boolean)


56
57
58
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 56

def safe_content_admin?
  @meeting.official?
end