Sha256: c917e453a2e52c866274d5c2785be0c63f4f00e5e8270bfd82cc4dcda65c87c2
Contents?: true
Size: 1.39 KB
Versions: 12
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true module Decidim module ContentBlocks class HighlightedElementsCell < Decidim::ViewModel include Decidim::CardHelper def elements @elements ||= case model.settings.order when "recent" base_relation.order_by_most_recent else base_relation.order_randomly(random_seed) end.limit(limit) end def base_relation raise "Please, overwrite this method. Inheriting classes should define their own base relation" end def show return if elements.blank? render end def published_components @published_components ||= if model.scope_name == "participatory_process_group_homepage" group = Decidim::ParticipatoryProcessGroup.find(model.scoped_resource_id) Decidim::Component.where(participatory_space: group.participatory_processes).published else Decidim::Component.none end end def block_id "#{model.scope_name}-#{model.manifest_name}".parameterize.gsub("_", "-") end private def limit 4 end def random_seed (rand * 2) - 1 end end end end
Version data entries
12 entries across 12 versions & 1 rubygems