Sha256: 74415da48bd329ba6dc57fcccc0989e2eaea7616461930ced754678fcd41c9dd

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Decidim
  module Debates
    # This cell renders the Medium (:m) debate card
    # for an given instance of a Debate
    class DebateMCell < Decidim::CardMCell
      include DebateCellsHelper

      def date
        render
      end

      private

      def title
        present(model).title
      end

      def resource_icon
        icon "debates", class: "icon--big"
      end

      def spans_multiple_dates?
        start_date != end_date
      end

      def debate_date
        return unless start_date && end_date
        return render(:multiple_dates) if spans_multiple_dates?
        render(:single_date)
      end

      def formatted_start_time
        model.start_time.strftime("%H:%M")
      end

      def formatted_end_time
        model.end_time.strftime("%H:%M")
      end

      def start_date
        return unless model.start_time
        model.start_time.to_date
      end

      def end_date
        return unless model.end_time
        model.end_time.to_date
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-debates-0.18.1 app/cells/decidim/debates/debate_m_cell.rb
decidim-debates-0.17.2 app/cells/decidim/debates/debate_m_cell.rb
decidim-debates-0.18.0 app/cells/decidim/debates/debate_m_cell.rb
decidim-debates-0.17.1 app/cells/decidim/debates/debate_m_cell.rb