Class: Wallaby::Resources::Index::HasManyHtml

Inherits:
Cell
  • Object
show all
Defined in:
app/views/wallaby/resources/index/has_many_html.rb

Overview

Html cell

Direct Known Subclasses

HasAndBelongsToManyHtml

Instance Method Summary collapse

Instance Method Details

#renderString



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/views/wallaby/resources/index/has_many_html.rb', line 9

def render
  unique_collection = value.uniq
  concat raw unique_collection.first(2).map { |item| show_link item, options: { readonly: true } }.join(', ')
  if unique_collection.length > 2
    title = [:label]
    body = unique_collection.map { |item| show_link item, options: { readonly: true } }.to_sentence.html_safe
    label = "#{unique_collection.length - 2} more"
    concat 'and'
    imodal title, body, label: label
  elsif unique_collection.blank?
    null
  end
end