Class: Spyro::ActionViewExtension::CollectionForHelper::Output::AdminTable

Inherits:
Table
  • Object
show all
Defined in:
lib/spyro/collections/outputs/admin_table.rb

Instance Method Summary collapse

Methods inherited from Table

#custom_value_formatted, #default_destroy_link_attributes, #format_value, #header, #render, #render_body, #render_cell_buttons, #render_footer, #render_header

Methods included from Fields

#format_boolean, #format_classy_enum, #format_cw_file, #format_cw_image, #format_datetime, #format_default, #format_email, #format_float, #format_html, #format_period, #format_prct, #format_progress, #format_string, #format_text, #format_url

Methods inherited from Base

#t

Constructor Details

#initialize(unicollection, helper, parser_class) ⇒ AdminTable

Returns a new instance of AdminTable.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/spyro/collections/outputs/admin_table.rb', line 12

def initialize unicollection, helper, parser_class
  super
  unicollection.meta[:html] ||= {}
  unicollection.meta[:html][:'data-model'] = unicollection.meta[:model_class].try(:underscore)
  unicollection.meta[:header] = ['<input type="checkbox" class="select all">'] + unicollection.meta[:header]
  unicollection.meta[:footer] = ["<span class='pull-left'>#{unicollection.meta[:footer].join}</span><span class='pull-right btns btn-group'>#{[*(unicollection.meta[:multiple_buttons] || unicollection.meta[:multiple_button])].join}</span>"]

  @unicollection.rows.each do |row|
    row[:data] = [UniData::Element.new(value: "<input type='checkbox' class='select one' data-id='#{row[:meta][:id]}'>", type: String, name: 'checkbox', db_type: String)] + row[:data]
  end
end