Module: Decidim::Assemblies::FilterAssembliesHelper

Included in:
AssembliesHelper
Defined in:
decidim-assemblies/app/helpers/decidim/assemblies/filter_assemblies_helper.rb

Overview

Helpers related to the Assemblies filter by type.

`filter` returns a Filter object from Decidim::FilterResource

Instance Method Summary collapse

Instance Method Details

#available_filtersObject


9
10
11
# File 'decidim-assemblies/app/helpers/decidim/assemblies/filter_assemblies_helper.rb', line 9

def available_filters
  @available_filters ||= [t("all", scope: "decidim.assemblies.filter")] + organization_assembly_types
end

#current_filter_nameObject


30
31
32
33
34
35
# File 'decidim-assemblies/app/helpers/decidim/assemblies/filter_assemblies_helper.rb', line 30

def current_filter_name
  type = AssembliesType.find_by(id: filter.type_id)
  return translated_attribute type.title if type

  t("all", scope: "decidim.assemblies.filter")
end

13
14
15
16
17
18
19
20
21
22
23
24
# File 'decidim-assemblies/app/helpers/decidim/assemblies/filter_assemblies_helper.rb', line 13

def filter_link(type_id)
  Decidim::Assemblies::Engine
    .routes
    .url_helpers
    .assemblies_path(
      filter: {
        scope_id: filter.scope_id,
        area_id: filter.area_id,
        type_id: type_id
      }
    )
end

#help_textObject


26
27
28
# File 'decidim-assemblies/app/helpers/decidim/assemblies/filter_assemblies_helper.rb', line 26

def help_text
  t("help", scope: "decidim.assemblies.filter")
end

#organization_assembly_typesObject


37
38
39
# File 'decidim-assemblies/app/helpers/decidim/assemblies/filter_assemblies_helper.rb', line 37

def organization_assembly_types
  AssembliesType.where(organization: current_organization)&.map { |type| [translated_attribute(type.title), type.id] }
end