-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Expand file tree
/
Copy pathpanel.rb
More file actions
31 lines (27 loc) · 721 Bytes
/
panel.rb
File metadata and controls
31 lines (27 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true
module ActiveAdmin
module Views
class Panel < ActiveAdmin::Component
builder_method :panel
def build(title, attributes = {})
super(attributes)
add_class "panel"
@title = h3(title.to_s, class: "panel-title")
@contents = div(class: "panel-body")
end
def add_child(child)
if @contents
@contents << child
else
super
end
end
# Override children? to only report children when the panel's
# contents have been added to. This ensures that the panel
# correctly appends string values, etc.
def children?
@contents.children?
end
end
end
end