Sha256: ea1de6e27a70749bae152b1c20878a1936c095e7dc2395f9e6a4232eca5094b0

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.20.1 app/cells/decidim/debates/debate_m_cell.rb
decidim-debates-0.20.0 app/cells/decidim/debates/debate_m_cell.rb
decidim-debates-0.19.1 app/cells/decidim/debates/debate_m_cell.rb
decidim-debates-0.19.0 app/cells/decidim/debates/debate_m_cell.rb