Class: Avo::Sidebar::BaseItemComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/avo/sidebar/base_item_component.rb

Direct Known Subclasses

GroupComponent, SectionComponent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item: nil) ⇒ BaseItemComponent

Returns a new instance of BaseItemComponent.



6
7
8
# File 'app/components/avo/sidebar/base_item_component.rb', line 6

def initialize(item: nil)
  @item = item
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



4
5
6
# File 'app/components/avo/sidebar/base_item_component.rb', line 4

def item
  @item
end

Instance Method Details

#collapsableObject



24
25
26
# File 'app/components/avo/sidebar/base_item_component.rb', line 24

def collapsable
  item.collapsable
end

#collapsedObject



28
29
30
# File 'app/components/avo/sidebar/base_item_component.rb', line 28

def collapsed
  item.collapsed
end

#itemsObject



10
11
12
# File 'app/components/avo/sidebar/base_item_component.rb', line 10

def items
  item.items
end

#keyObject



14
15
16
17
18
19
20
21
22
# File 'app/components/avo/sidebar/base_item_component.rb', line 14

def key
  result = "avo.#{request.host}.main_menu.#{item.name.to_s.underscore}"

  if item.icon.present?
    result += ".#{item.icon.parameterize.underscore}"
  end

  result
end