Sha256: a49a2c5324af86704c0522b85d757c257af48e85b7c5295f8c5826e7728dd88b

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 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 unless number.present?

        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)
        %Q{class=active} if scope.to_s == current_scope.to_s
      end

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

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-accountability-0.1.2 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.1.1 app/helpers/decidim/accountability/application_helper.rb
decidim-accountability-0.1.0 app/helpers/decidim/accountability/application_helper.rb