Sha256: 176a6734159e5bdfb72375ac229ff5f83d3e216b07d17771640dc66e7ffc6c39

Contents?: true

Size: 1.58 KB

Versions: 16

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

module Decidim
  module Accountability
    # Custom helpers, scoped to the meetings 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_leaf_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(feature_settings.categories_label).presence || t("results.home.categories_label", scope: "decidim.accountability")
      end

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

      def heading_parent_level_results(count)
        text = translated_attribute(feature_settings.heading_parent_level_results).presence
        if text
          "#{count} #{text}"
        else
          t("results.count.results_count", scope: "decidim.accountability", count: count)
        end
      end

      def heading_leaf_level_results(count)
        text = translated_attribute(feature_settings.heading_leaf_level_results).presence
        if text
          "#{count} #{text}"
        else
          t("results.count.results_count", scope: "decidim.accountability", count: count)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
decidim-accountability-0.10.1 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.10.0 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.9.3 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.9.2 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.9.1 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.9.0 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.8.4 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.8.3 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.8.2 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.8.1 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.8.0 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.7.4 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.7.3 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.7.2 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.7.1 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.7.0 app/helpers/decidim/accountability/application_helper.rb