Class: ActiveAdmin::Views::TableFor
- Inherits:
-
Arbre::HTML::Table
- Object
- Arbre::HTML::Table
- ActiveAdmin::Views::TableFor
show all
- Defined in:
- lib/active_admin/views/components/table_for.rb
Defined Under Namespace
Classes: Column
Instance Method Summary
collapse
Instance Method Details
#build(obj, *attrs) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/active_admin/views/components/table_for.rb', line 11
def build(obj, *attrs)
options = attrs.
@sortable = options.delete(:sortable)
@collection = obj.respond_to?(:each) && !obj.is_a?(Hash) ? obj : [obj]
@resource_class = options.delete(:i18n)
@resource_class ||= @collection.klass if @collection.respond_to? :klass
@columns = []
@row_class = options.delete(:row_class)
build_table
super(options)
add_class "data-table"
columns(*attrs)
end
|
#column(*args, &block) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/active_admin/views/components/table_for.rb', line 31
def column(*args, &block)
options = default_options.merge(args.)
title = args[0]
data = args[1] || args[0]
col = Column.new(title, data, @resource_class, options, &block)
@columns << col
within @header_row do
(col)
end
@collection.each_with_index do |resource, index|
within @tbody.children[index] do
build_table_cell col, resource
end
end
end
|
#columns(*attrs) ⇒ Object
27
28
29
|
# File 'lib/active_admin/views/components/table_for.rb', line 27
def columns(*attrs)
attrs.each { |attr| column(attr) }
end
|
#sortable? ⇒ Boolean
52
53
54
|
# File 'lib/active_admin/views/components/table_for.rb', line 52
def sortable?
!!@sortable
end
|
#tag_name ⇒ Object
7
8
9
|
# File 'lib/active_admin/views/components/table_for.rb', line 7
def tag_name
"table"
end
|