Sha256: 5bc90bdac92697ac2ec5cb1121b585c008991743643497bd21eea9f3a91615cb

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 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.join("/")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.25.2 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.25.1 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.25.0 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.25.0.rc4 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.25.0.rc3 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.25.0.rc2 app/cells/decidim/content_blocks/hero_cell.rb
decidim-core-0.25.0.rc1 app/cells/decidim/content_blocks/hero_cell.rb