Module: Decidim::Meetings::ApplicationHelper

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

Overview

Custom helpers, scoped to the meetings engine.

Instance Method Summary collapse

Methods included from RichTextEditorHelper

included, #text_editor_for

Methods included from Comments::CommentsHelper

#comments_for, #inline_comments_for

Methods included from MapHelper

#meetings_data_for_map

Methods included from PaginateHelper

#decidim_paginate, #per_page

Instance Method Details

#activity_filter_valuesObject

Options to filter meetings by activity.


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

def activity_filter_values
  [
    ["all", t("decidim.meetings.meetings.filters.all")],
    ["my_meetings", t("decidim.meetings.meetings.filters.my_meetings")]
  ]
end

#filter_date_valuesObject


43
44
45
46
47
48
49
50
51
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 43

def filter_date_values
  TreeNode.new(
    TreePoint.new("", t("decidim.meetings.meetings.filters.date_values.all")),
    [
      TreePoint.new("upcoming", t("decidim.meetings.meetings.filters.date_values.upcoming")),
      TreePoint.new("past", t("decidim.meetings.meetings.filters.date_values.past"))
    ]
  )
end

#filter_origin_valuesObject


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


31
32
33
34
35
36
37
38
39
40
41
# File 'decidim-meetings/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

Returns:

  • (Boolean)

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

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)

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

def online_or_hybrid_meeting?(meeting)
  meeting.online_meeting? || meeting.hybrid_meeting?
end

#prevent_timeout_secondsObject


73
74
75
76
77
78
79
80
81
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 73

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.


69
70
71
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 69

def render_meeting_body(meeting)
  Decidim::ContentProcessor.render(render_sanitized_content(meeting, :description), "div")
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.

Returns:

  • (Boolean)

64
65
66
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 64

def safe_content?
  rich_text_editor_in_public_views? || @meeting.official?
end