Module: Decidim::Sortitions::SortitionsHelper
- Includes:
 - Decidim::SanitizeHelper, TranslationsHelper
 
- Included in:
 - SortitionMetadataCell
 
- Defined in:
 - app/helpers/decidim/sortitions/sortitions_helper.rb
 
Instance Method Summary collapse
- #component_name ⇒ Object
 - #filter_sections_sortitions ⇒ Object
 - #filter_state_values ⇒ Object
 - #proposal_path(proposal) ⇒ Object
 - 
  
    
      #sortition_category_label(sortition)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Generates the sortition category label.
 - 
  
    
      #sortition_proposal_candidate_ids(sortition)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Show list of candidate proposals for a sortition.
 
Instance Method Details
#component_name ⇒ Object
      13 14 15  | 
    
      # File 'app/helpers/decidim/sortitions/sortitions_helper.rb', line 13 def component_name (defined?(current_component) && translated_attribute(current_component&.name).presence) || t("decidim.components.sortitions.name") end  | 
  
#filter_sections_sortitions ⇒ Object
      42 43 44 45 46 47 48 49 50 51 52  | 
    
      # File 'app/helpers/decidim/sortitions/sortitions_helper.rb', line 42 def filter_sections_sortitions sections = [{ method: :with_any_state, collection: filter_state_values, label_scope: "decidim.sortitions.sortitions.filters", id: "state" }] if current_participatory_space.categories.any? sections.append( method: :with_category, collection: filter_categories_values, label_scope: "decidim.sortitions.sortitions.filters", id: "category" ) end sections.reject { |item| item[:collection].blank? } end  | 
  
#filter_state_values ⇒ Object
      54 55 56 57 58 59 60  | 
    
      # File 'app/helpers/decidim/sortitions/sortitions_helper.rb', line 54 def filter_state_values [ ["all", t("all", scope: "decidim.sortitions.sortitions.filters")], ["active", t("active", scope: "decidim.sortitions.sortitions.filters")], ["cancelled", t("cancelled", scope: "decidim.sortitions.sortitions.filters")] ] end  | 
  
#proposal_path(proposal) ⇒ Object
      9 10 11  | 
    
      # File '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
      18 19 20 21 22 23 24 25 26  | 
    
      # File 'app/helpers/decidim/sortitions/sortitions_helper.rb', line 18 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.
      29 30 31 32 33 34 35 36 37 38 39 40  | 
    
      # File 'app/helpers/decidim/sortitions/sortitions_helper.rb', line 29 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  |