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



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

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

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



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

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)


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

def children?
  @contents.children?
end

#header_action(*args) ⇒ Object



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

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

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