Class: Jav::ItemsHolder
- Inherits:
-
Object
- Object
- Jav::ItemsHolder
- Defined in:
- lib/jav/items_holder.rb
Instance Attribute Summary collapse
-
#invalid_fields ⇒ Object
Returns the value of attribute invalid_fields.
-
#items ⇒ Object
Returns the value of attribute items.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Instance Method Summary collapse
- #add_item(instance) ⇒ Object
-
#field(field_name, **args, &block) ⇒ Object
Adds a field to the bag.
- #heading(body = nil, **args, &block) ⇒ Object
-
#initialize ⇒ ItemsHolder
constructor
A new instance of ItemsHolder.
- #panel(panel_name = nil, **args, &block) ⇒ Object
- #row(**args, &block) ⇒ Object
- #sidebar(instance) ⇒ Object
- #tab(name, **args, &block) ⇒ Object
- #tabs(instance) ⇒ Object
- #tool(klass, **args) ⇒ Object
Constructor Details
#initialize ⇒ ItemsHolder
Returns a new instance of ItemsHolder.
6 7 8 9 10 |
# File 'lib/jav/items_holder.rb', line 6 def initialize @items = [] @items_index = 0 @invalid_fields = [] end |
Instance Attribute Details
#invalid_fields ⇒ Object
Returns the value of attribute invalid_fields.
4 5 6 |
# File 'lib/jav/items_holder.rb', line 4 def invalid_fields @invalid_fields end |
#items ⇒ Object
Returns the value of attribute items.
4 5 6 |
# File 'lib/jav/items_holder.rb', line 4 def items @items end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
3 4 5 |
# File 'lib/jav/items_holder.rb', line 3 def tools @tools end |
Instance Method Details
#add_item(instance) ⇒ Object
65 66 67 68 69 |
# File 'lib/jav/items_holder.rb', line 65 def add_item(instance) @items << instance increment_order_index end |
#field(field_name, **args, &block) ⇒ Object
Adds a field to the bag
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jav/items_holder.rb', line 13 def field(field_name, **args, &block) field_parser = Jav::Dsl::FieldParser.new(id: field_name, order_index: @items_index, **args, &block).parse if field_parser.invalid? as = args.fetch(:as, nil) # End execution ehre and add the field to the invalid_fileds payload so we know to wanr the developer about that. # @todo: Make sure this warning is still active return add_invalid_field({ name: field_name, as: as, # resource: resource_class.name, message: "There's an invalid field configuration for this resource. <br/> <code class='px-1 py-px rounded-sm bg-red-600'>field :#{field_name}, as: #{as}</code>" }) end add_item field_parser.instance end |
#heading(body = nil, **args, &block) ⇒ Object
55 56 57 58 59 |
# File 'lib/jav/items_holder.rb', line 55 def heading(body = nil, **args, &block) field = Jav::Fields::HeadingField.new(body, **args) add_item field end |
#panel(panel_name = nil, **args, &block) ⇒ Object
49 50 51 52 53 |
# File 'lib/jav/items_holder.rb', line 49 def panel(panel_name = nil, **args, &block) panel = Jav::PanelBuilder.parse_block(name: panel_name, **args, &block) add_item panel end |
#row(**args, &block) ⇒ Object
40 41 42 |
# File 'lib/jav/items_holder.rb', line 40 def row(**args, &block) add_item Jav::RowBuilder.parse_block(**args, &block) end |
#sidebar(instance) ⇒ Object
61 62 63 |
# File 'lib/jav/items_holder.rb', line 61 def (instance) add_item instance end |
#tab(name, **args, &block) ⇒ Object
36 37 38 |
# File 'lib/jav/items_holder.rb', line 36 def tab(name, **args, &block) add_item Jav::TabBuilder.parse_block(name: name, **args, &block) end |
#tabs(instance) ⇒ Object
32 33 34 |
# File 'lib/jav/items_holder.rb', line 32 def tabs(instance) add_item instance end |
#tool(klass, **args) ⇒ Object
44 45 46 47 |
# File 'lib/jav/items_holder.rb', line 44 def tool(klass, **args) instance = klass.new(**args) add_item instance end |