Module: Decidim::Votings::VotingsHelper

Includes:
CheckBoxesTreeHelper
Included in:
ContentBlocks::MainDataCell, VotingDropdownMetadataCell
Defined in:
decidim-elections/app/helpers/decidim/votings/votings_helper.rb

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

#date_filter_valuesObject



8
9
10
11
12
13
14
15
16
17
# File 'decidim-elections/app/helpers/decidim/votings/votings_helper.rb', line 8

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

#filter_sectionsObject



19
20
21
# File 'decidim-elections/app/helpers/decidim/votings/votings_helper.rb', line 19

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

#voting_nav_items(participatory_space) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'decidim-elections/app/helpers/decidim/votings/votings_helper.rb', line 23

def voting_nav_items(participatory_space)
  components = participatory_space.components.published.or(Decidim::Component.where(id: try(:current_component)))

  (
    [
      if participatory_space.check_census_enabled?
        {
          name: t("layouts.decidim.voting_navigation.check_census"),
          url: decidim_votings.voting_check_census_path(participatory_space),
          active: is_active_link?(decidim_votings.voting_check_census_path(participatory_space), :exclusive)
        }
      end
    ] + components.map do |component|
      {
        name: translated_attribute(component.name),
        url: main_component_path(component),
        active: is_active_link?(main_component_path(component), :inclusive) && !is_active_link?("election_log", /election_log$/)
      }
    end +
    [
      {
        name: t("layouts.decidim.voting_navigation.election_log"),
        url: decidim_votings.voting_elections_log_path(participatory_space),
        active: is_active_link?(decidim_votings.voting_elections_log_path(participatory_space), :exclusive) || is_active_link?("election_log", /election_log$/)
      }
    ]
  ).compact
end