Class: Decidim::Sortitions::SortitionMetadataCell
  
  
  
  
  
    - Inherits:
 
    - 
      CardMetadataCell
      
        
          - Object
 
          
            - CardMetadataCell
 
          
            - Decidim::Sortitions::SortitionMetadataCell
 
          
        
        show all
      
     
  
  
  
  
  
  
  
      - Includes:
 
      - SortitionsHelper
 
  
  
  
  
  
  
    - Defined in:
 
    - app/cells/decidim/sortitions/sortition_metadata_cell.rb
 
  
  
 
Overview
  
    
This cell renders the assembly metadata for l card
   
 
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #component_name, #filter_sections_sortitions, #filter_state_values, #proposal_path, #sortition_category_label, #sortition_proposal_candidate_ids
  
  
  
  Constructor Details
  
    
  
  
    
Returns a new instance of SortitionMetadataCell.
   
 
  
  
    
      
11
12
13
14
15 
     | 
    
      # File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 11
def initialize(*)
  super
  @items.prepend(*sortition_items)
end 
     | 
  
 
  
 
  
    Instance Method Details
    
      
  
  
    #badge_item  ⇒ Object 
  
  
  
  
    
      
35
36
37
38
39 
     | 
    
      # File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 35
def badge_item
  {
    text: content_tag(:span, class: "label #{state_classes}") { badge_name }
  }
end
     | 
  
 
    
      
  
  
    #badge_name  ⇒ Object 
  
  
  
  
    
      
45
46
47
48
49 
     | 
    
      # File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 45
def badge_name
  return t("filters.cancelled", scope: "decidim.sortitions.sortitions") if model.cancelled?
  t("filters.active", scope: "decidim.sortitions.sortitions")
end
     | 
  
 
    
      
  
  
    #count_item  ⇒ Object 
  
  
  
  
    
      
21
22
23
24
25
26 
     | 
    
      # File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 21
def count_item
  {
    text: data_with_text(proposals_count, t("decidim.sortitions.sortitions.sortition.selected_proposals", count: proposals_count)),
    icon: "chat-new-line"
  }
end
     | 
  
 
    
      
  
  
    #data_with_text(data, text)  ⇒ Object 
  
  
  
  
    
      
51
52
53 
     | 
    
      # File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 51
def data_with_text(data, text)
  "#{content_tag(:strong) { data }}#{content_tag(:span) { text }}".html_safe
end
     | 
  
 
    
      
  
  
    #has_badge?  ⇒ Boolean 
  
  
  
  
    
      
41
42
43 
     | 
    
      # File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 41
def has_badge?
  false
end 
     | 
  
 
    
      
  
  
    #proposals_count  ⇒ Object 
  
  
  
  
    
      
61
62
63 
     | 
    
      # File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 61
def proposals_count
  @proposals_count = model.proposals.count
end 
     | 
  
 
    
      
  
  
    #seed_item  ⇒ Object 
  
  
  
  
    
      
28
29
30
31
32
33 
     | 
    
      # File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 28
def seed_item
  {
    text: data_with_text(model.seed, t("random_seed", scope: "decidim.sortitions.sortitions.sortition")),
    icon: "seedling-line"
  }
end
     | 
  
 
    
      
  
  
    #sortition_items  ⇒ Object 
  
  
  
  
    
      
17
18
19 
     | 
    
      # File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 17
def sortition_items
  [count_item, seed_item, badge_item]
end 
     | 
  
 
    
      
  
  
    #state_classes  ⇒ Object 
  
  
  
  
    
      
55
56
57
58
59 
     | 
    
      # File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 55
def state_classes
  return "alert" if model.cancelled?
  "success"
end 
     |