Sha256: 6962cbf38532e12b2538bb2109ed5c3b4ebc4e46105ac076b0618fc90acd305d
Contents?: true
Size: 1.2 KB
Versions: 8
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true module Decidim # This cell is used to render a collection of linked resources for a # resource. It is based on the equivalent helper method # linked_resources_for. # # The `model` must be a resource to get the links from. # # Available options # - `:type` => The String type fo the resources we want to render. # Required. # - `:link_name` => The String name of the link between the resources. # Required. # # Example: # # cell( # "decidim/linked_resources_for", # result, # type: :proposals, # link_name: "included_proposals" # ) class LinkedResourcesForCell < Decidim::ViewModel include Cell::ViewModel::Partial include Decidim::ApplicationHelper delegate :current_settings, to: :controller alias resource model def show return if linked_resources.blank? render :show end private def linked_resources @linked_resources ||= resource.linked_resources(type, link_name).group_by { |linked_resource| linked_resource.class.name } end def type options[:type] end def link_name options[:link_name] end end end
Version data entries
8 entries across 8 versions & 1 rubygems