Sha256: 0da422cca873979a49ee7a6f158567762c4c8445d3e4d1b3eee5414728c19040

Contents?: true

Size: 1.21 KB

Versions: 46

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Decidim
  module Sortitions
    module SortitionsHelper
      include Decidim::SanitizeHelper
      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

46 entries across 46 versions & 1 rubygems

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