Class: Avo::Resources::Items::TabGroup::Builder
- Inherits:
-
Object
- Object
- Avo::Resources::Items::TabGroup::Builder
- Includes:
- Concerns::BorrowItemsHolder
- Defined in:
- lib/avo/resources/items/tab_group.rb
Instance Method Summary collapse
-
#build ⇒ Object
Fetch the tab.
- #field(field_name, **args, &block) ⇒ Object
-
#initialize(name:, id:, parent:, style: nil, **args) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(name:, id:, parent:, style: nil, **args) ⇒ Builder
Returns a new instance of Builder.
70 71 72 73 |
# File 'lib/avo/resources/items/tab_group.rb', line 70 def initialize(name:, id:, parent:, style: nil, **args) @group = Avo::Resources::Items::TabGroup.new(name: name, id: id, style: style, **args) @items_holder = Avo::Resources::Items::Holder.new(parent: parent, from: self) end |
Instance Method Details
#build ⇒ Object
Fetch the tab
76 77 78 79 |
# File 'lib/avo/resources/items/tab_group.rb', line 76 def build @group.items_holder = @items_holder @group end |
#field(field_name, **args, &block) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/avo/resources/items/tab_group.rb', line 50 def field(field_name, **args, &block) parsed = Avo::Dsl::FieldParser.new(id: field_name, order_index: @items_index, **args, &block).parse field_instance = parsed.instance name = field_instance.name tab = Avo::Resources::Items::Tab.new name: name if field_instance.has_own_panel? tab.items_holder.add_item parsed.instance else # If the field is not in a panel, create one and add it panel = Avo::Resources::Items::Panel.new name: name panel.items_holder.add_item parsed.instance # Add that panel to the items_holder tab.items_holder.add_item panel end @items_holder.tabs tab end |