Sha256: a5daa36ccb7e4cd6fa6cd71676d813f04a72785643b9147e41d206eac78f081a

Contents?: true

Size: 1.61 KB

Versions: 45

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

module Decidim
  module Accountability
    # Custom helpers, scoped to the accountability engine.
    #
    module ApplicationHelper
      include PaginateHelper
      include Decidim::Comments::CommentsHelper

      def display_percentage(number)
        return if number.blank?

        number_to_percentage(number, precision: 1, strip_insignificant_zeros: true, locale: I18n.locale)
      end

      def display_count(count)
        heading_parent_level_results(count)
      end

      def active_class_if_current(scope)
        "class=active" if scope.to_s == current_scope.to_s
      end

      def categories_label
        translated_attribute(component_settings.categories_label).presence || t("results.home.categories_label", scope: "decidim.accountability")
      end

      def subcategories_label
        translated_attribute(component_settings.subcategories_label).presence || t("results.home.subcategories_label", scope: "decidim.accountability")
      end

      def heading_parent_level_results(count)
        text = translated_attribute(component_settings.heading_parent_level_results).presence
        if text
          pluralize(count, text)
        else
          t("results.count.results_count", scope: "decidim.accountability", count: count)
        end
      end

      def heading_leaf_level_results(count)
        text = translated_attribute(component_settings.heading_leaf_level_results).presence
        if text
          pluralize(count, text)
        else
          t("results.count.results_count", scope: "decidim.accountability", count: count)
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
decidim-accountability-0.27.9 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.27.8 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.27.7 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.27.6 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.26.10 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.26.9 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.27.5 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.26.8 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.27.4 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.27.3 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.26.7 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.26.5 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.27.2 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.27.1 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.26.4 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.27.0 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.26.3 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.27.0.rc2 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.27.0.rc1 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.26.2 app/helpers/decidim/accountability/application_helper.rb