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
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/thecore_settings/rails_admin_config.rb', line 3
def self.included(base)
if base.respond_to?(:rails_admin)
base.rails_admin do
navigation_label I18n.t("admin.settings.label")
list do
if Object.const_defined?('RailsAdminToggleable')
field :enabled, :toggle
else
field :enabled
end
field :kind
field :ns
field :name
field :raw do
pretty_value do
if bindings[:object].file_kind? and !defined?(Shrine) and bindings[:object].to_path.present?
if bindings[:object].file.url.blank?
"-"
else
"<a href='#{CGI::escapeHTML(bindings[:object].file.url)}'>#{CGI::escapeHTML(bindings[:object].to_path)}</a>".html_safe
end
elsif bindings[:object].image_kind? and !defined?(Shrine) and !bindings[:object].file.nil?
if bindings[:object].file.url.blank?
"-"
else
"<a href='#{CGI::escapeHTML(bindings[:object].file.url)}'><img src='#{CGI::escapeHTML(bindings[:object].file.url)}' /></a>".html_safe
end
else
value
end
end
end
if ::Settings.table_exists?
nss = ::ThecoreSettings::Setting.pluck(:ns).uniq.map { |c| "ns_#{c.gsub('-', '_')}".to_sym }
scopes([nil] + nss)
end
end
edit do
field :enabled
field :label do
read_only true
help false
end
field :kind do
read_only true
help false
end
field :raw do
partial "setting_value"
visible do
!bindings[:object].upload_kind?
end
end
if Settings.file_uploads_supported
field :file, Settings.file_uploads_engine do
visible do
bindings[:object].upload_kind?
end
end
end
end
end
else
puts "[thecore_settings] Problem: model does not respond to rails_admin: this should not happen"
end
end
|