Class: Decidim::CollapsibleAuthorsCell

Inherits:
ViewModel
  • Object
show all
Defined in:
app/cells/decidim/collapsible_authors_cell.rb

Overview

This cell renders a collapsible list of authors. Each element from the array of Users will be rendered with the :cell cell.

Constant Summary collapse

MAX_ITEMS_STACKED =
3

Instance Method Summary collapse

Instance Method Details

#showObject



9
10
11
12
13
14
# File 'app/cells/decidim/collapsible_authors_cell.rb', line 9

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

#single_author_optionsObject



16
17
18
# File 'app/cells/decidim/collapsible_authors_cell.rb', line 16

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

#visible_authorsObject



20
21
22
# File 'app/cells/decidim/collapsible_authors_cell.rb', line 20

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