Method: Storefront::Components::Table#initialize
- Defined in:
- lib/storefront/components/table.rb
#initialize(template, *args) ⇒ Table
Returns a new instance of Table.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/storefront/components/table.rb', line 6 def initialize(template, *args) @template = template = args. record_or_key = args.shift @key = record_key(record_or_key) @row_index = 0 @cell_index = 0 @scope = :table @headers = [] [:summary] ||= "Table for #{key.titleize}" [:class] = ["data-table", [:class]].compact.uniq.join(" ") [:role] = :grid data = .delete(:data) || {} #data[:url] = options[:url] || @template.controller.request.path #data[:for] = options[:for] || options[:model] || @key data[:total] = [:total] if [:total] data[:page] = [:page] if [:page] data[:count] = [:count] if [:count] aria = .delete(:aria) || {} aria[:"aria-multiselectable"] = false unless aria.has_key?(:"aria-multiselectable") || [:multiselect] == true [:data] = data [:id] ||= "#{record_or_key.to_s}-table" @options = end |