Sha256: 952aa68a8ba8d7a49517e4fc0252bd1711d0c039a09c9ffb03a3c0aa5efc0d8c

Contents?: true

Size: 1012 Bytes

Versions: 5

Compression:

Stored size: 1012 Bytes

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.background_image.big.url
      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.join("/")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.24.3 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.24.2 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.24.1 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.24.0 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.24.0.rc2 app/cells/decidim/content_blocks/hero_cell.rb