Sha256: 6ded44b05ffb73fb7348ecc826f887e24a644e0f570a55398fa70606353df760

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require "cell/partial"

module Decidim
  module Debates
    # This cell renders the List (:l) debate card
    # for a given instance of a Debate
    class DebateLCell < Decidim::CardLCell
      include Decidim::SanitizeHelper
      delegate :component_settings, to: :controller

      alias debate model

      def has_description?
        true
      end

      def author_presenter
        if model.official?
          Decidim::Core::OfficialAuthorPresenter.new
        else
          model.normalized_author.presenter
        end
      end

      def title
        presenter.title(html_escape: true)
      end

      def description
        attribute = model.try(:short_description) || model.try(:body) || model.description
        text = translated_attribute(attribute)

        decidim_sanitize(html_truncate(text, length: 240))
      end

      private

      def presenter
        present(model)
      end

      def metadata_cell
        "decidim/debates/debate_card_metadata"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-debates-0.28.0 app/cells/decidim/debates/debate_l_cell.rb
decidim-debates-0.28.0.rc5 app/cells/decidim/debates/debate_l_cell.rb
decidim-debates-0.28.0.rc4 app/cells/decidim/debates/debate_l_cell.rb