Module: Decidim::Initiatives::ApplicationHelper

Includes:
CheckBoxesTreeHelper, DateRangeHelper, InitiativesHelper
Defined in:
decidim-initiatives/app/helpers/decidim/initiatives/application_helper.rb

Overview

Custom helpers, scoped to the initiatives engine.

Instance Method Summary collapse

Methods included from InitiativesHelper

#initiative_nav_items

Methods included from DateRangeHelper

#format_date_range

Methods included from CheckBoxesTreeHelper

#check_boxes_tree_options, #filter_areas_values, #filter_categories_values, #filter_global_scopes_values, #filter_origin_values, #filter_scopes_values, #filter_text_for, #filter_tree_from_array, #flat_filter_values, #resource_filter_scope_values

Instance Method Details

#component_nameObject



42
43
44
# File 'decidim-initiatives/app/helpers/decidim/initiatives/application_helper.rb', line 42

def component_name
  (defined?(current_component) && translated_attribute(current_component&.name).presence) || t("decidim.admin.models.initiatives.fields.title")
end

#filter_states_valuesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'decidim-initiatives/app/helpers/decidim/initiatives/application_helper.rb', line 12

def filter_states_values
  TreeNode.new(
    TreePoint.new("", t("decidim.initiatives.application_helper.filter_state_values.all")),
    [
      TreePoint.new("open", t("decidim.initiatives.application_helper.filter_state_values.open")),
      TreeNode.new(
        TreePoint.new("closed", t("decidim.initiatives.application_helper.filter_state_values.closed")),
        [
          TreePoint.new("accepted", t("decidim.initiatives.application_helper.filter_state_values.accepted")),
          TreePoint.new("rejected", t("decidim.initiatives.application_helper.filter_state_values.rejected"))
        ]
      ),
      TreePoint.new("answered", t("decidim.initiatives.application_helper.filter_state_values.answered"))
    ]
  )
end

#filter_types_valuesObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'decidim-initiatives/app/helpers/decidim/initiatives/application_helper.rb', line 29

def filter_types_values
  types_values = Decidim::InitiativesType.where(organization: current_organization).map do |type|
    TreeNode.new(
      TreePoint.new(type.id.to_s, type.title[I18n.locale.to_s])
    )
  end

  TreeNode.new(
    TreePoint.new("", t("decidim.initiatives.application_helper.filter_type_values.all")),
    types_values
  )
end