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


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