Class: Decidim::Sortitions::SortitionMetadataCell

Inherits:
CardMetadataCell
  • Object
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

Methods included from SortitionsHelper

#component_name, #filter_sections_sortitions, #filter_state_values, #proposal_path, #sortition_category_label, #sortition_proposal_candidate_ids

Constructor Details

#initializeSortitionMetadataCell

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_itemObject



35
36
37
38
39
# File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 35

def badge_item
  {
    text: (:span, class: "label #{state_classes}") { badge_name }
  }
end

#badge_nameObject



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_itemObject



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)
  "#{(:strong) { data }}#{(:span) { text }}".html_safe
end

#has_badge?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 41

def has_badge?
  false
end

#proposals_countObject



61
62
63
# File 'app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 61

def proposals_count
  @proposals_count = model.proposals.count
end

#seed_itemObject



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_itemsObject



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_classesObject



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