Sha256: f27f067a0bcb2994f7189e83ac87c554becff9ebddfd17f986f7195976dd6ad0
Contents?: true
Size: 1.05 KB
Versions: 15
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true require "cell/partial" module Decidim # This cell renders the list of endorsers. # # Example: # # cell("decidim/endorsers_list", my_component) class EndorsersListCell < Decidim::ViewModel include ApplicationHelper MAX_ITEMS_STACKED = 3 def show return render :full if full_list? render end def full_endorsers_list render end def endorsers_count base_relation.count end private def full_list? options[:layout] == :full end # Finds the correct author for each endorsement. # # Returns an Array of presented Users/UserGroups def visible_endorsers @visible_endorsers ||= base_relation.limit(MAX_ITEMS_STACKED).map { |identity| present(identity.normalized_author) } end def full_endorsers @full_endorsers ||= base_relation.map { |identity| present(identity.normalized_author) } end def base_relation @base_relation ||= model.endorsements.for_listing.includes(:author, :user_group) end end end
Version data entries
15 entries across 15 versions & 1 rubygems