Class: Decidim::Debates::DebateCardMetadataCell

Inherits:
CardMetadataCell
  • Object
show all
Includes:
ActionView::Helpers::DateHelper, LayoutHelper
Defined in:
app/cells/decidim/debates/debate_card_metadata_cell.rb

Overview

This cell renders metadata for an instance of a Meeting

Instance Method Summary collapse

Constructor Details

#initializeDebateCardMetadataCell

Returns a new instance of DebateCardMetadataCell.



14
15
16
17
18
# File 'app/cells/decidim/debates/debate_card_metadata_cell.rb', line 14

def initialize(*)
  super

  @items.prepend(*debate_items)
end

Instance Method Details

#category_itemObject



20
21
22
23
24
25
26
27
# File 'app/cells/decidim/debates/debate_card_metadata_cell.rb', line 20

def category_item
  return if category.blank?

  {
    text: category.translated_name,
    icon: resource_type_icon_key("Decidim::Category")
  }
end

#debate_itemsObject



29
30
31
# File 'app/cells/decidim/debates/debate_card_metadata_cell.rb', line 29

def debate_items
  [duration, comments_count_item, endorsements_count_item, category_item, coauthors_item]
end

#durationObject



33
34
35
36
37
38
39
40
# File 'app/cells/decidim/debates/debate_card_metadata_cell.rb', line 33

def duration
  text = format_date_range(debate.start_time, debate.end_time) || t("open", scope: "decidim.debates.debates.show")

  {
    text:,
    icon: "time-line"
  }
end