Class: ActiveElement::Components::ItemTable
- Inherits:
-
Object
- Object
- ActiveElement::Components::ItemTable
- Includes:
- LinkHelpers, SecretFields
- Defined in:
- lib/active_element/components/item_table.rb
Overview
A table component for rendering the fields of a single object horizontally.
Constant Summary
Constants included from SecretFields
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
Instance Method Summary collapse
-
#initialize(controller, item:, fields:, class_name: nil, model_name: nil, edit: false, new: false, destroy: false, style: nil, row_class: nil, title: nil, **_kwargs) ⇒ ItemTable
constructor
A new instance of ItemTable.
-
#locals ⇒ Object
rubocop:disable Metrics/MethodLength.
- #model ⇒ Object
- #template ⇒ Object
Methods included from SecretFields
Constructor Details
#initialize(controller, item:, fields:, class_name: nil, model_name: nil, edit: false, new: false, destroy: false, style: nil, row_class: nil, title: nil, **_kwargs) ⇒ ItemTable
Returns a new instance of ItemTable.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_element/components/item_table.rb', line 12 def initialize(controller, item:, fields:, class_name: nil, model_name: nil, edit: false, new: false, destroy: false, style: nil, row_class: nil, title: nil, **_kwargs) @controller = controller @class_name = class_name @model_name = model_name @item = item @fields = fields @destroy = destroy @edit = edit @new = new @style = style @row_class = row_class @title = title end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
10 11 12 |
# File 'lib/active_element/components/item_table.rb', line 10 def controller @controller end |
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
10 11 12 |
# File 'lib/active_element/components/item_table.rb', line 10 def model_name @model_name end |
Instance Method Details
#locals ⇒ Object
rubocop:disable Metrics/MethodLength
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/active_element/components/item_table.rb', line 31 def locals # rubocop:disable Metrics/MethodLength { component: self, class_name: class_name, item: item, fields: Util::FieldMapping.new(self, fields, class_name).mapped_fields, destroy: destroy, edit: edit, new: new, style: style, row_class_mapper: row_class_mapper, title: title } end |
#model ⇒ Object
46 47 48 |
# File 'lib/active_element/components/item_table.rb', line 46 def model item.class.is_a?(ActiveModel::Naming) ? item.class : nil end |
#template ⇒ Object
27 28 29 |
# File 'lib/active_element/components/item_table.rb', line 27 def template 'active_element/components/table/item' end |