Module: Decidim::Meetings::Directory::ApplicationHelper

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

Instance Method Summary collapse

Methods included from CheckBoxesTreeHelper

#check_boxes_tree_options, #filter_categories_values, #filter_origin_values, #filter_scopes_values, #filter_scopes_values_from, #filter_scopes_values_from_parent, #filter_tree_from, #resource_filter_scope_values

Methods included from SanitizeHelper

#decidim_html_escape, #decidim_sanitize, #decidim_sanitize_editor, #decidim_sanitize_newsletter, #decidim_url_escape, included

Methods included from Comments::CommentsHelper

#comments_for, #inline_comments_for

Methods included from MeetingsHelper

#author_presenter_for, #calculate_start_and_end_time_of_agenda_items, #current_user_groups?, #display_duration_agenda_items, #google_calendar_event_url, #meeting_description, #meeting_type_badge_css_class, #registration_code_help_text, #validation_state_for

Methods included from ResourceHelper

#linked_classes_filter_values_for, #linked_classes_for, #linked_resources_for, #resource_locator, #resource_title

Methods included from TranslationsHelper

empty_translatable, ensure_translatable, multi_translation, translated_in_current_locale?

Methods included from TranslatableAttributes

#default_locale?

Methods included from ApplicationHelper

#filter_origin_values, #iframe_embed_or_live_event_page?, #online_or_hybrid_meeting?, #prevent_timeout_seconds, #render_meeting_body, #safe_content?

Methods included from RichTextEditorHelper

included, #text_editor_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

Methods included from ApplicationHelper

#cell, #edit_link, #extra_admin_link, #html_truncate, #present, #prevent_timeout_seconds, #resolve_presenter_class, #step_cta_url

Methods included from CacheHelper

#cache

Methods included from AmendmentsHelper

#accept_and_reject_buttons_for, #action_button_card_for, #allowed_to_accept_and_reject?, #allowed_to_promote?, #amend_button_for, #amenders_list_for, #amendments_enabled?, #amendments_for, #amendments_form_field_for, #amendments_form_fields_label, #amendments_form_fields_value, #can_participate_in_private_space?, #can_react_to_emendation?, #emendation_actions_for, #emendation_announcement_for, #promote_button_for, #render_emendation_body

Methods included from ContextualHelpHelper

#floating_help

Methods included from ScopesHelper

#has_visible_scopes?, #scope_name_for_picker, #scopes_picker_field, #scopes_picker_filter, #scopes_picker_tag

Methods included from DecidimFormHelper

#areas_for_select, #base_error_messages, #decidim_form_for, #decidim_form_slug_url, #editor_field_tag, #form_field_has_error?, #form_required_explanation, #name_with_locale, #scopes_picker_field_tag, #tab_element_class_for, #translated_field_tag

Methods included from OmniauthHelper

#normalize_provider_name, #oauth_icon, #provider_name

Instance Method Details

#activity_filter_valuesObject

Options to filter meetings by activity.


122
123
124
125
126
127
# File 'decidim-meetings/app/helpers/decidim/meetings/directory/application_helper.rb', line 122

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

#directory_filter_categories_valuesObject


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'decidim-meetings/app/helpers/decidim/meetings/directory/application_helper.rb', line 81

def directory_filter_categories_values
  participatory_spaces = current_organization.public_participatory_spaces
  list_of_ps = participatory_spaces.flat_map do |current_participatory_space|
    next unless current_participatory_space.respond_to?(:categories)

    sorted_main_categories = current_participatory_space.categories.first_class.includes(:subcategories).sort_by do |category|
      [category.weight, translated_attribute(category.name, current_organization)]
    end

    categories_values = categories_values(sorted_main_categories)

    next if categories_values.empty?

    key_point = current_participatory_space.class.name.gsub("::", "__") + current_participatory_space.id.to_s

    TreeNode.new(
      TreePoint.new(key_point, translated_attribute(current_participatory_space.title, current_organization)),
      categories_values
    )
  end

  list_of_ps.compact!
  TreeNode.new(
    TreePoint.new("", t("decidim.meetings.application_helper.filter_category_values.all")),
    list_of_ps
  )
end

#directory_filter_origin_valuesObject


109
110
111
112
113
114
115
116
117
118
119
# File 'decidim-meetings/app/helpers/decidim/meetings/directory/application_helper.rb', line 109

def directory_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"))
  origin_values << TreePoint.new("user_group", t("decidim.meetings.meetings.filters.origin_values.user_groups")) if current_organization.user_groups_enabled?

  TreeNode.new(
    TreePoint.new("", t("decidim.meetings.meetings.filters.origin_values.all")),
    origin_values
  )
end

#directory_filter_scopes_valuesObject


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'decidim-meetings/app/helpers/decidim/meetings/directory/application_helper.rb', line 39

def directory_filter_scopes_values
  main_scopes = current_organization.scopes.top_level

  scopes_values = main_scopes.includes(:scope_type, :children).flat_map do |scope|
    TreeNode.new(
      TreePoint.new(scope.id.to_s, translated_attribute(scope.name, current_organization)),
      scope_children_to_tree(scope)
    )
  end

  scopes_values.prepend(TreePoint.new("global", t("decidim.scopes.global")))

  TreeNode.new(
    TreePoint.new("", t("decidim.meetings.application_helper.filter_scope_values.all")),
    scopes_values
  )
end

#directory_meeting_spaces_valuesObject


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

def directory_meeting_spaces_values
  participatory_spaces = current_organization.public_participatory_spaces

  spaces = participatory_spaces.collect(&:model_name).uniq.map do |participatory_space|
    TreePoint.new(participatory_space.name.underscore, participatory_space.human(count: 2))
  end

  TreeNode.new(
    TreePoint.new("", t("decidim.meetings.application_helper.filter_meeting_space_values.all")),
    spaces
  )
end

#filter_date_valuesObject


29
30
31
32
33
34
35
36
37
# File 'decidim-meetings/app/helpers/decidim/meetings/directory/application_helper.rb', line 29

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_type_valuesObject


17
18
19
20
21
22
23
24
25
26
27
# File 'decidim-meetings/app/helpers/decidim/meetings/directory/application_helper.rb', line 17

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

#scope_children_to_tree(scope) ⇒ Object


57
58
59
60
61
62
63
64
65
66
# File 'decidim-meetings/app/helpers/decidim/meetings/directory/application_helper.rb', line 57

def scope_children_to_tree(scope)
  return unless scope.children.any?

  scope.children.includes(:scope_type, :children).flat_map do |child|
    TreeNode.new(
      TreePoint.new(child.id.to_s, translated_attribute(child.name, current_organization)),
      scope_children_to_tree(child)
    )
  end
end