Class: Avo::Resources::Items::TabGroup

Inherits:
Object
  • Object
show all
Includes:
Concerns::HasItemType, Concerns::HasItems, Concerns::IsResourceItem, Concerns::IsVisible, Concerns::VisibleInDifferentViews
Defined in:
lib/avo/resources/items/tab_group.rb

Defined Under Namespace

Classes: Builder

Instance Attribute Summary collapse

Attributes included from Concerns::VisibleInDifferentViews

#show_on_edit, #show_on_index, #show_on_new, #show_on_preview, #show_on_show

Attributes included from Concerns::IsVisible

#visible

Attributes included from Concerns::HasItems

#items_holder

Attributes included from Concerns::IsResourceItem

#resource, #view

Instance Method Summary collapse

Methods included from Concerns::VisibleInDifferentViews

#except_on, #hide_on, #initialize_views, #only_on, #post_initialize, #show_on, #show_on_create, #show_on_update, #visible_in_view?

Methods included from Concerns::IsVisible

#visible?

Methods included from Concerns::HasItemType

#is_field?, #is_heading?, #is_main_panel?, #is_panel?, #is_row?, #is_sidebar?, #is_tab?, #is_tab_group?, #is_tool?

Methods included from Concerns::HasItems

#fields, #get_field, #get_field_definitions, #get_fields, #get_items, #get_preview_fields, #invalid_fields, #is_empty?, #items, #only_fields, #tab_groups, #visible_items

Methods included from Concerns::IsResourceItem

#visible?

Methods included from Concerns::Hydration

#hydrate

Constructor Details

#initialize(index: 0, view: nil, style: nil, id: nil, name: nil, **args) ⇒ TabGroup

Returns a new instance of TabGroup.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/avo/resources/items/tab_group.rb', line 13

def initialize(index: 0, view: nil, style: nil, id: nil, name: nil, **args)
  @index = index
  @items_holder = Avo::Resources::Items::Holder.new
  @view = Avo::ViewInquirer.new view
  @style = style
  @id = id
  @name = name
  @args = args
  @visible = args[:visible]

  post_initialize if respond_to?(:post_initialize)
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



9
10
11
# File 'lib/avo/resources/items/tab_group.rb', line 9

def index
  @index
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/avo/resources/items/tab_group.rb', line 11

def name
  @name
end

#styleObject

Returns the value of attribute style.



10
11
12
# File 'lib/avo/resources/items/tab_group.rb', line 10

def style
  @style
end

Instance Method Details

#group_paramObject



41
42
43
# File 'lib/avo/resources/items/tab_group.rb', line 41

def group_param
  "tab-group_#{id}"
end

#idObject Also known as: to_param

The user might assign an id to a group. If not, we’ll use the name. If not, we’ll use the index



29
30
31
32
33
34
# File 'lib/avo/resources/items/tab_group.rb', line 29

def id
  return @id if @id.present?
  return @name.parameterize if @name.present?

  index
end

#turbo_frame_idObject



37
38
39
# File 'lib/avo/resources/items/tab_group.rb', line 37

def turbo_frame_id
  "#{Avo::Resources::Items::TabGroup.to_s.parameterize} #{index}".parameterize
end