Sha256: 83f3a7540b88134d6fd1f010003fd4ea9d1bc0db56c16cd93af7926fc33a6b44

Contents?: true

Size: 1.17 KB

Versions: 29

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Decidim
  module Sortitions
    module SortitionsHelper
      include Decidim::TranslationsHelper

      def proposal_path(proposal)
        EngineRouter.main_proxy(proposal.component).proposal_path(proposal)
      end

      # Generates the sortition category label
      def sortition_category_label(sortition)
        if sortition.category.present?
          return I18n.t("show.category",
                        scope: "decidim.sortitions.sortitions",
                        category: translated_attribute(sortition.category.name))
        end

        I18n.t("show.any_category", scope: "decidim.sortitions.sortitions")
      end

      # Show list of candidate proposals for a sortition. Selected sortition ids will appear with bold font.
      def sortition_proposal_candidate_ids(sortition)
        result = []
        sortition.candidate_proposals.each do |proposal_id|
          result << if sortition.selected_proposals.include? proposal_id
                      "<b>#{proposal_id}</b>"
                    else
                      proposal_id.to_s
                    end
        end

        result.join(", ").html_safe
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
decidim-sortitions-0.12.2 app/helpers/decidim/sortitions/sortitions_helper.rb
decidim-sortitions-0.13.0 app/helpers/decidim/sortitions/sortitions_helper.rb
decidim-sortitions-0.12.1 app/helpers/decidim/sortitions/sortitions_helper.rb
decidim-sortitions-0.13.0.pre1 app/helpers/decidim/sortitions/sortitions_helper.rb
decidim-sortitions-0.12.0 app/helpers/decidim/sortitions/sortitions_helper.rb
decidim-sortitions-0.11.2 app/helpers/decidim/sortitions/sortitions_helper.rb
decidim-sortitions-0.12.0.pre app/helpers/decidim/sortitions/sortitions_helper.rb
decidim-sortitions-0.11.1 app/helpers/decidim/sortitions/sortitions_helper.rb
decidim-sortitions-0.11.0.pre1 app/helpers/decidim/sortitions/sortitions_helper.rb