Class: ActiveAdmin::Views::TableFor
- Inherits:
-
Arbre::HTML::Table
- Object
- Arbre::HTML::Element
- Arbre::HTML::Tag
- Arbre::HTML::Table
- ActiveAdmin::Views::TableFor
- Defined in:
- lib/active_admin/views/components/table_for.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Column
Constant Summary
Constants included from Arbre::HTML
Arbre::HTML::AUTO_BUILD_ELEMENTS, Arbre::HTML::HTML5_ELEMENTS
Instance Attribute Summary
Attributes inherited from Arbre::HTML::Tag
Attributes inherited from Arbre::HTML::Element
Instance Method Summary collapse
- #build(collection, options = {}) ⇒ Object
- #column(*args, &block) ⇒ Object
- #sortable? ⇒ Boolean
- #tag_name ⇒ Object
-
#visible_columns ⇒ Object
Returns the columns to display based on the conditional block.
Methods inherited from Arbre::HTML::Table
Methods inherited from Arbre::HTML::Tag
#add_class, #class_list, #class_names, #get_attribute, #has_attribute?, #id, #id!, #id=, #initialize, #remove_attribute, #remove_class, #set_attribute, #to_html
Methods inherited from Arbre::HTML::Element
#+, #<<, #add_child, #assigns, builder_method, #content, #content=, #document, #each, #get_elements_by_tag_name, #helpers, #html_safe, #indent_level, #initialize, #parent?, #remove_child, #to_ary, #to_html, #to_s, #to_str
Methods included from Arbre::HTML::BuilderMethods
#build_tag, #current_dom_context, #insert_tag, #insert_text_node_if_string, #with_current_dom_context
Methods included from Arbre::HTML
#current_dom_context, #helpers, #method_missing
Constructor Details
This class inherits a constructor from Arbre::HTML::Table
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Arbre::HTML
Instance Method Details
#build(collection, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/active_admin/views/components/table_for.rb', line 10 def build(collection, = {}) @sortable = .delete(:sortable) @resource_class = .delete(:i18n) @collection = collection @columns = [] build_table super() end |
#column(*args, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_admin/views/components/table_for.rb', line 19 def column(*args, &block) = .merge(args.last.is_a?(::Hash) ? args.pop : {}) title = args[0] data = args[1] || args[0] col = Column.new(title, data, , &block) @columns << col # Build our header item within @header_row do build_table_header(col) end # Add a table cell for each item @collection.each_with_index do |item, i| within @tbody.children[i] do build_table_cell(col, item) end end end |
#sortable? ⇒ Boolean
40 41 42 |
# File 'lib/active_admin/views/components/table_for.rb', line 40 def sortable? @sortable end |
#tag_name ⇒ Object
6 7 8 |
# File 'lib/active_admin/views/components/table_for.rb', line 6 def tag_name 'table' end |
#visible_columns ⇒ Object
Returns the columns to display based on the conditional block
45 46 47 |
# File 'lib/active_admin/views/components/table_for.rb', line 45 def visible_columns @visible_columns ||= @columns.select{|col| col.display_column? } end |