Sha256: 0a6c747005421fd0bed1fe0f067a8557aa549d908f62dd80d9839d3780d8e6b0

Contents?: true

Size: 1.01 KB

Versions: 13

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Decidim
  module Debates
    # This cell renders metadata for an instance of a Meeting
    class DebateCardMetadataCell < Decidim::CardMetadataCell
      include Decidim::LayoutHelper
      include ActionView::Helpers::DateHelper

      alias debate model

      delegate :type_of_meeting, :start_time, :end_time, :category, :withdrawn?, to: :debate

      def initialize(*)
        super

        @items.prepend(*debate_items)
      end

      def category_item
        return if category.blank?

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

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

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

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-debates-0.29.1 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.28.4 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.29.0 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.28.3 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.29.0.rc4 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.29.0.rc3 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.29.0.rc2 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.29.0.rc1 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.28.2 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.28.1 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.28.0 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.28.0.rc5 app/cells/decidim/debates/debate_card_metadata_cell.rb
decidim-debates-0.28.0.rc4 app/cells/decidim/debates/debate_card_metadata_cell.rb