Module: Decidim::Meetings::ApplicationHelper

Includes:
CheckBoxesTreeHelper, Comments::CommentsHelper, FollowableHelper, Decidim::MapHelper, MapHelper, RichTextEditorHelper, SanitizeHelper, PaginateHelper
Included in:
HighlightedMeetingsForComponentCell, MeetingsHelper, PublicParticipantsListCell
Defined in:
app/helpers/decidim/meetings/application_helper.rb

Overview

Custom helpers, scoped to the meetings engine.

Instance Method Summary collapse

Methods included from MapHelper

#meetings_data_for_map

Instance Method Details

#activity_filter_valuesObject

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_tagsObject



92
93
94
95
# File 'app/helpers/decidim/meetings/application_helper.rb', line 92

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 '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 '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 '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)


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

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)


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_secondsObject



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 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
# 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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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

def safe_content_admin?
  @meeting.official?
end