Sha256: 99cac8117ee3dba978906ecffc0d0f7dddb882f7a18e5daff1abc419e2128ab9

Contents?: true

Size: 922 Bytes

Versions: 6

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Accountability
    # Helpers needed to render the navigation breadcrumbs in results.
    #
    module BreadcrumbHelper
      def current_scope
        params[:filter][:with_scope] if params[:filter]
      end

      def progress_calculator(scope_id, category_id)
        Decidim::Accountability::ResultsCalculator.new(current_component, scope_id, category_id).progress
      end

      def category
        return if (category_id = params.dig(:filter, :with_category)).blank?

        @category ||= current_participatory_space.categories.find(category_id.is_a?(Array) ? category_id.first : category_id)
      end

      def parent_categories(category)
        return [] if category&.parent.blank?

        [*parent_categories(category.parent), category.parent]
      end

      def categories_hierarchy
        parent_categories(category)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-accountability-0.29.1 app/helpers/decidim/accountability/breadcrumb_helper.rb
decidim-accountability-0.29.0 app/helpers/decidim/accountability/breadcrumb_helper.rb
decidim-accountability-0.29.0.rc4 app/helpers/decidim/accountability/breadcrumb_helper.rb
decidim-accountability-0.29.0.rc3 app/helpers/decidim/accountability/breadcrumb_helper.rb
decidim-accountability-0.29.0.rc2 app/helpers/decidim/accountability/breadcrumb_helper.rb
decidim-accountability-0.29.0.rc1 app/helpers/decidim/accountability/breadcrumb_helper.rb