Sha256: 92ef20e5a95586e5ee0f9dd8ac34d2e874737f27c7c00c0423208ea0a787f20f

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    # This cell renders a collapsible list of the proposal coauthors.
    #
    # Available sizes:
    #  - `:small` => collapses after 3 elements.
    #  - `:default` => collapses after 7 elements. If not specified, this one is
    #    used.
    #
    # Example:
    #
    #    cell("decidim/proposals/coauthorships", @proposal)
    class CoauthorshipsCell < Decidim::ViewModel
      include Decidim::ApplicationHelper

      def show
        if model.official?
          cell "decidim/author", present(model).author, from: model
        else
          cell(
            "decidim/collapsible_authors",
            authors_for(model),
            cell_name: "decidim/author",
            cell_options: { extra_classes: ["author-data--small"] },
            size: :small,
            from: model
          )
        end
      end

      private

      def authors_for(coauthorable)
        coauthorable.identities.map { |identity| present(identity) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-proposals-0.13.1 app/cells/decidim/proposals/coauthorships_cell.rb
decidim-proposals-0.13.0 app/cells/decidim/proposals/coauthorships_cell.rb
decidim-proposals-0.13.0.pre1 app/cells/decidim/proposals/coauthorships_cell.rb