Sha256: 3936599dba8f8e2a4787580886ef06166361507dd3378ff849ab7a918f1cd04b

Contents?: true

Size: 1.68 KB

Versions: 13

Compression:

Stored size: 1.68 KB

Contents

# frozen_string_literal: true

module Decidim
  module Initiatives
    # Custom helpers, scoped to the initiatives engine.
    #
    module ApplicationHelper
      include Decidim::CheckBoxesTreeHelper
      include Decidim::DateRangeHelper
      include InitiativesHelper

      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

      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

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-initiatives-0.29.1 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.28.4 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.29.0 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.28.3 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.29.0.rc4 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.29.0.rc3 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.29.0.rc2 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.29.0.rc1 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.28.2 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.28.1 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.28.0 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.28.0.rc5 app/helpers/decidim/initiatives/application_helper.rb
decidim-initiatives-0.28.0.rc4 app/helpers/decidim/initiatives/application_helper.rb