Module: RailsAdminSettings::RailsAdminConfig

Included in:
Setting
Defined in:
lib/rails_admin_settings/rails_admin_config.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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
# File 'lib/rails_admin_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 :type
        field :ns
        field :name
        field :raw
      end

      edit do
        field :enabled
        field :label do
          read_only true
          help false
        end
        field :type do
          read_only true
          help false
        end
        field :raw do
          partial "setting_value"
          visible do
            !bindings[:object].file_type?
          end
        end
        if Settings.file_uploads_supported
          field :file, Settings.file_uploads_engine do
            visible do
              bindings[:object].file_type?
            end
          end
        end
      end
    end
  else
    puts "[rails_admin_settings] Problem: model does not respond to rails_admin: this should not happen"
  end
end