Class: Panda::Core::Admin::TableComponent
- Defined in:
- app/components/panda/core/admin/table_component.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
Instance Method Summary collapse
- #column(label, width: nil, &cell_block) ⇒ Object
-
#initialize(**props) ⇒ TableComponent
constructor
A new instance of TableComponent.
- #view_template(&block) ⇒ Object
Methods inherited from Base
#after_template, #attrs, #before_template, #default_attrs, #merge_attrs, #tailwind_merge_attrs
Constructor Details
#initialize(**props) ⇒ TableComponent
Returns a new instance of TableComponent.
13 14 15 16 |
# File 'app/components/panda/core/admin/table_component.rb', line 13 def initialize(**props) super @columns = [] end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
11 12 13 |
# File 'app/components/panda/core/admin/table_component.rb', line 11 def columns @columns end |
Instance Method Details
#column(label, width: nil, &cell_block) ⇒ Object
29 30 31 |
# File 'app/components/panda/core/admin/table_component.rb', line 29 def column(label, width: nil, &cell_block) @columns << Column.new(label, width, &cell_block) end |
#view_template(&block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/components/panda/core/admin/table_component.rb', line 18 def view_template(&block) # Capture the block to populate columns instance_eval(&block) if block_given? if @rows.any? render_table_with_rows else render_empty_table end end |