Sha256: eb49f66561b97caca2f4e85e42ba661fbc2c0ea71a2f60891b5f17245e2533db

Contents?: true

Size: 1.47 KB

Versions: 5

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

require "cell/partial"

module Decidim
  module Proposals
    # This cell renders the List (:l) proposal card
    # for an instance of a Proposal
    class ProposalLCell < Decidim::CardLCell
      delegate :component_settings, to: :controller

      alias proposal model

      def title
        present(proposal).title(html_escape: true)
      end

      private

      def metadata_cell
        "decidim/proposals/proposal_metadata"
      end

      def cache_hash
        hash = []
        hash << I18n.locale.to_s
        hash << model.cache_key_with_version
        hash << model.proposal_votes_count
        hash << model.endorsements_count
        hash << model.comments_count
        hash << Digest::MD5.hexdigest(model.component.cache_key_with_version)
        hash << Digest::MD5.hexdigest(resource_image_path) if resource_image_path
        hash << render_space? ? 1 : 0
        if current_user
          hash << current_user.cache_key_with_version
          hash << current_user.follows?(model) ? 1 : 0
        end
        hash << model.follows_count
        hash << Digest::MD5.hexdigest(model.authors.map(&:cache_key_with_version).to_s)
        hash << (model.must_render_translation?(model.organization) ? 1 : 0) if model.respond_to?(:must_render_translation?)
        hash << model.component.participatory_space.active_step.id if model.component.participatory_space.try(:active_step)

        hash.join(Decidim.cache_key_separator)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-proposals-0.28.2 app/cells/decidim/proposals/proposal_l_cell.rb
decidim-proposals-0.28.1 app/cells/decidim/proposals/proposal_l_cell.rb
decidim-proposals-0.28.0 app/cells/decidim/proposals/proposal_l_cell.rb
decidim-proposals-0.28.0.rc5 app/cells/decidim/proposals/proposal_l_cell.rb
decidim-proposals-0.28.0.rc4 app/cells/decidim/proposals/proposal_l_cell.rb