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.


52
53
54
55
56
57
# File 'decidim-meetings/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_valuesObject


43
44
45
46
47
48
49
# File 'decidim-meetings/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_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)

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

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)

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

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

#prevent_timeout_secondsObject


76
77
78
79
80
81
82
83
84
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 76

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.


67
68
69
70
71
72
73
74
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 67

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.

Returns:

  • (Boolean)

62
63
64
# File 'decidim-meetings/app/helpers/decidim/meetings/application_helper.rb', line 62

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