Sha256: 98e099f20c32fb1336589641d2de53cc8b5f0fea615f69a65a8befc4b37d54b7
Contents?: true
Size: 1.11 KB
Versions: 6
Compression:
Stored size: 1.11 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 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
6 entries across 6 versions & 1 rubygems