Sha256: e7dcf26db694cd21537b84d0d2c7a49f3eb589ab292553fa2f3160905385a57c

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Decidim
  module ContentBlocks
    class HeroCell < Decidim::ViewModel
      include Decidim::CtaButtonHelper
      include Decidim::SanitizeHelper

      # Needed so that the `CtaButtonHelper` can work.
      def decidim_participatory_processes
        Decidim::ParticipatoryProcesses::Engine.routes.url_helpers
      end

      def translated_welcome_text
        translated_attribute(model.settings.welcome_text)
      end

      def background_image
        model.images_container.attached_uploader(:background_image).path(variant: :big)
      end

      private

      # A MD5 hash of model attributes because is needed because
      # the model doesn't respond to cache_key_with_version nor updated_at method
      def cache_hash
        hash = []
        hash << "decidim/content_blocks/hero"
        hash << Digest::MD5.hexdigest(model.attributes.to_s)
        hash << current_organization.cache_key_with_version
        hash << I18n.locale.to_s
        hash << background_image

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.27.8 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.27.7 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.27.6 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.27.5 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.27.4 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.27.3 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.27.2 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.27.1 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.27.0 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.27.0.rc2 app/cells/decidim/content_blocks/hero_cell.rb