Sha256: 4993b7e77342b67118a4a0176d5acf88df647011a1fcde4e012cb715f3e635c4

Contents?: true

Size: 662 Bytes

Versions: 13

Compression:

Stored size: 662 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders a collapsible list of authors. Each element from the
  # array of Users will be rendered with the `:cell` cell.
  class CollapsibleAuthorsCell < Decidim::ViewModel
    MAX_ITEMS_STACKED = 3

    def show
      return cell("decidim/author", model.first, single_author_options.merge(options)) if model.length == 1
      return render :stack if options[:stack]

      render
    end

    def single_author_options
      options[:stack] ? { skip_profile_link: true } : { layout: :compact }
    end

    def visible_authors
      @visible_authors ||= model.take(MAX_ITEMS_STACKED)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.28.4 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.29.0 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.28.3 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.29.0.rc4 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.29.0.rc3 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.29.0.rc2 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.29.0.rc1 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.28.2 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.28.1 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.28.0 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.28.0.rc5 app/cells/decidim/collapsible_authors_cell.rb
decidim-core-0.28.0.rc4 app/cells/decidim/collapsible_authors_cell.rb