Class: ActiveAdmin::Views::Panel

Inherits:
Component
  • Object
show all
Defined in:
lib/active_admin/views/components/panel.rb

Direct Known Subclasses

Comments::Views::Comments, SidebarSection

Instance Method Summary collapse

Instance Method Details

#add_child(child) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/active_admin/views/components/panel.rb', line 14

def add_child(child)
  if @contents
    @contents << child
  else
    super
  end
end

#build(title, attributes = {}) ⇒ Object



7
8
9
10
11
12
# File 'lib/active_admin/views/components/panel.rb', line 7

def build(title, attributes = {})
  super(attributes)
  add_class "panel"
  @title = h3(title.to_s)
  @contents = div(class: "panel_contents")
end

#children?Boolean

Override children? to only report children when the panel's contents have been added to. This ensures that the panel correcly appends string values, etc.

Returns:

  • (Boolean)


25
26
27
# File 'lib/active_admin/views/components/panel.rb', line 25

def children?
  @contents.children?
end

#header_action(*args) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/active_admin/views/components/panel.rb', line 29

def header_action(*args)
  action = args[0]

  @title << div(class: 'header_action') do
    action
  end
end