Module: Decidim::Elections::ApplicationHelper

Includes:
CheckBoxesTreeHelper
Defined in:
decidim-elections/app/helpers/decidim/elections/application_helper.rb

Overview

Custom helpers, scoped to the elections engine.

Instance Method Summary collapse

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



25
26
27
# File 'decidim-elections/app/helpers/decidim/elections/application_helper.rb', line 25

def component_name
  (defined?(current_component) && translated_attribute(current_component&.name).presence) || t("decidim.components.elections.name")
end

#date_filter_valuesObject



10
11
12
13
14
15
16
17
18
19
# File 'decidim-elections/app/helpers/decidim/elections/application_helper.rb', line 10

def date_filter_values
  TreeNode.new(
    TreePoint.new("", t("elections.elections.filters.all", scope: "decidim")),
    [
      TreePoint.new("active", t("elections.elections.filters.active", scope: "decidim")),
      TreePoint.new("upcoming", t("elections.elections.filters.upcoming", scope: "decidim")),
      TreePoint.new("finished", t("elections.elections.filters.finished", scope: "decidim"))
    ]
  )
end

#filter_sectionsObject



21
22
23
# File 'decidim-elections/app/helpers/decidim/elections/application_helper.rb', line 21

def filter_sections
  @filter_sections ||= [{ method: :with_any_date, collection: date_filter_values, label_scope: "decidim.elections.elections.filters", id: "date" }]
end