Class: Decidim::Elections::ElectionCardMetadataCell

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

Overview

This cell renders metadata for an instance of a Meeting

Instance Method Summary collapse

Methods included from LabelHelper

#election_status_with_label

Constructor Details

#initializeElectionCardMetadataCell

Returns a new instance of ElectionCardMetadataCell.



15
16
17
18
19
# File 'app/cells/decidim/elections/election_card_metadata_cell.rb', line 15

def initialize(*)
  super

  @items.prepend(*election_items)
end

Instance Method Details

#current_dateObject



29
30
31
# File 'app/cells/decidim/elections/election_card_metadata_cell.rb', line 29

def current_date
  @current_date ||= Time.current.to_time
end

#election_itemsObject



21
22
23
# File 'app/cells/decidim/elections/election_card_metadata_cell.rb', line 21

def election_items
  [label, progress_item]
end

#end_dateObject



39
40
41
42
43
# File 'app/cells/decidim/elections/election_card_metadata_cell.rb', line 39

def end_date
  return if end_at.blank?

  @end_date ||= end_at.to_time
end

#labelObject



25
26
27
# File 'app/cells/decidim/elections/election_card_metadata_cell.rb', line 25

def label
  { text: election_status_with_label(election) }
end

#progress_textObject



45
46
47
48
49
50
51
52
# File 'app/cells/decidim/elections/election_card_metadata_cell.rb', line 45

def progress_text
  if election.published_results? && election.finished?
    return t("published_results", scope: "decidim.metadata.progress",
                                  end_date: l(election.results_at.to_time, format: :decidim_short))
  end

  super
end

#start_dateObject



33
34
35
36
37
# File 'app/cells/decidim/elections/election_card_metadata_cell.rb', line 33

def start_date
  return if start_at.blank?

  @start_date ||= start_at.to_time
end