Sha256: 245e949d5a346fcf99c3c7499a94d4ae20faec66b5194f42e8fb2193132728b4

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 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), strip_tags: true)
      end

      private

      def presenter
        present(model)
      end

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

Version data entries

10 entries across 10 versions & 1 rubygems

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