-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
show.rb
59 lines (48 loc) · 1.44 KB
/
show.rb
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
module ActiveAdmin
module Views
module Pages
class Show < Base
def config
active_admin_config.get_page_presenter(:show) || super
end
def title
if config[:title]
render_or_call_method_or_proc_on(resource, config[:title])
else
assigns[:page_title] || default_title
end
end
def main_content
if config.block
# Eval the show config from the controller
instance_exec resource, &config.block
else
default_main_content
end
end
def attributes_table(*args, &block)
panel(I18n.t('active_admin.details', model: active_admin_config.resource_label)) do
attributes_table_for resource, *args, &block
end
end
protected
def default_title
title = display_name(resource)
if title.nil? || title.empty? || title == resource.to_s
title = "#{active_admin_config.resource_label} ##{resource.id}"
end
title
end
module DefaultMainContent
def default_main_content(&block)
attributes_table(*default_attribute_table_rows, &block)
end
def default_attribute_table_rows
resource.class.columns.collect{|column| column.name.to_sym }
end
end
include DefaultMainContent
end
end
end
end