Module: Decidim::Sortitions::SortitionsHelper

Includes:
Decidim::SanitizeHelper, TranslationsHelper
Defined in:
decidim-sortitions/app/helpers/decidim/sortitions/sortitions_helper.rb

Instance Method Summary collapse

Methods included from TranslationsHelper

empty_translatable, ensure_translatable, multi_translation, translated_in_current_locale?

Methods included from TranslatableAttributes

#default_locale?

Methods included from Decidim::SanitizeHelper

#decidim_html_escape, #decidim_sanitize, #decidim_sanitize_newsletter, #decidim_url_escape, included

Instance Method Details

#proposal_path(proposal) ⇒ Object


9
10
11
# File 'decidim-sortitions/app/helpers/decidim/sortitions/sortitions_helper.rb', line 9

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

#sortition_category_label(sortition) ⇒ Object

Generates the sortition category label


14
15
16
17
18
19
20
21
22
# File 'decidim-sortitions/app/helpers/decidim/sortitions/sortitions_helper.rb', line 14

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

#sortition_proposal_candidate_ids(sortition) ⇒ Object

Show list of candidate proposals for a sortition. Selected sortition ids will appear with bold font.


25
26
27
28
29
30
31
32
33
34
35
36
# File 'decidim-sortitions/app/helpers/decidim/sortitions/sortitions_helper.rb', line 25

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