Class: Avo::Sidebar

Inherits:
Object
  • Object
show all
Includes:
Concerns::IsResourceItem, Concerns::VisibleItems, Fields::FieldExtensions::VisibleInDifferentViews
Defined in:
lib/avo/sidebar.rb

Defined Under Namespace

Classes: BaseItemComponent, GroupComponent, HeadingComponent, ItemSwitcherComponent, LinkComponent, SectionComponent

Instance Attribute Summary collapse

Attributes included from Fields::FieldExtensions::VisibleInDifferentViews

#show_on_edit, #show_on_index, #show_on_new, #show_on_show

Instance Method Summary collapse

Methods included from Fields::FieldExtensions::VisibleInDifferentViews

#except_on, #hide_on, #only_on, #show_on, #show_on_create, #show_on_update, #visible_on?

Methods included from Concerns::VisibleItems

#hydrate, #items, #visible, #visible?, #visible_items

Methods included from Concerns::IsResourceItem

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

Constructor Details

#initialize(name: nil, view: nil, **args) ⇒ Sidebar

Returns a new instance of Sidebar.



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

def initialize(name: nil, view: nil, **args)
  # Initialize the visibility markers
  super

  @name = name
  @items_holder = Avo::ItemsHolder.new
  @view = view

  show_on args[:show_on] if args[:show_on].present?
  hide_on args[:hide_on] if args[:hide_on].present?
  only_on args[:only_on] if args[:only_on].present?
  except_on args[:except_on] if args[:except_on].present?
end

Instance Attribute Details

#items_holderObject

Returns the value of attribute items_holder.



11
12
13
# File 'lib/avo/sidebar.rb', line 11

def items_holder
  @items_holder
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/avo/sidebar.rb', line 9

def name
  @name
end

#viewObject (readonly)

Returns the value of attribute view.



10
11
12
# File 'lib/avo/sidebar.rb', line 10

def view
  @view
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/avo/sidebar.rb', line 27

def empty?
  visible_items.blank?
end