ack_rails_admin_settings 1.2.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c625464ebb0d8c0390f4b26d77c94f7e0cbb5368
4
- data.tar.gz: bb903abfec5bab855b1ebbf4016cfeccfeb4c44b
3
+ metadata.gz: 6663058ce20b74441ee8340c97500cc9908cc091
4
+ data.tar.gz: 83bcf698383dbdc75b3f2d348ee51ec80aa1bea6
5
5
  SHA512:
6
- metadata.gz: 0370fd2c5e9a1fc2db6b372ad0a113f0a4f621fb014290180494250467c65bcceed51db1d40061281a9bf676d3412b1528d8c6ba4fdf8a36d768e2d8f2132ff3
7
- data.tar.gz: 6405d6621997576159c927e40eba5b0721d51f8d3970370b998d089cd4d913c963533114dded31b0c527f16bb7e83d85eca322d0b234e3eebd7aaf440818fb33
6
+ metadata.gz: 6afa909a56d795a158f0d4a2f36eb1871892a4aef293803396cd362938cf9fba86c501327c05670cc1e545d0bf563914c513849da87aa5ddbbc3bef5e2a5eb60
7
+ data.tar.gz: 1bb12aa2f4ba502387039761ad4321cb8919825f99d49bbaad7466b44a241686b333053c390ce8af8e168c57ccf63eac1bc113d349d1f587c48b5e5c6246638f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.2.3
2
+ - Hash and Array types.
3
+
1
4
  ## 1.2.2
2
5
  - Loadable Settings. You can cancel load some settings for save time, memory, etc. Because of cache, perhaps.
3
6
  - DELEGATE :p, :puts and :block_given? for Kernel. Prevent Settings.p and etc
data/Gemfile.lock CHANGED
@@ -1,92 +1,92 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ack_rails_admin_settings (1.2.2.1)
4
+ ack_rails_admin_settings (1.2.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actioncable (5.0.1)
10
- actionpack (= 5.0.1)
11
- nio4r (~> 1.2)
9
+ actioncable (5.1.3)
10
+ actionpack (= 5.1.3)
11
+ nio4r (~> 2.0)
12
12
  websocket-driver (~> 0.6.1)
13
- actionmailer (5.0.1)
14
- actionpack (= 5.0.1)
15
- actionview (= 5.0.1)
16
- activejob (= 5.0.1)
13
+ actionmailer (5.1.3)
14
+ actionpack (= 5.1.3)
15
+ actionview (= 5.1.3)
16
+ activejob (= 5.1.3)
17
17
  mail (~> 2.5, >= 2.5.4)
18
18
  rails-dom-testing (~> 2.0)
19
- actionpack (5.0.1)
20
- actionview (= 5.0.1)
21
- activesupport (= 5.0.1)
19
+ actionpack (5.1.3)
20
+ actionview (= 5.1.3)
21
+ activesupport (= 5.1.3)
22
22
  rack (~> 2.0)
23
23
  rack-test (~> 0.6.3)
24
24
  rails-dom-testing (~> 2.0)
25
25
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
26
- actionview (5.0.1)
27
- activesupport (= 5.0.1)
26
+ actionview (5.1.3)
27
+ activesupport (= 5.1.3)
28
28
  builder (~> 3.1)
29
- erubis (~> 2.7.0)
29
+ erubi (~> 1.4)
30
30
  rails-dom-testing (~> 2.0)
31
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
32
- activejob (5.0.1)
33
- activesupport (= 5.0.1)
31
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
32
+ activejob (5.1.3)
33
+ activesupport (= 5.1.3)
34
34
  globalid (>= 0.3.6)
35
- activemodel (5.0.1)
36
- activesupport (= 5.0.1)
37
- activerecord (5.0.1)
38
- activemodel (= 5.0.1)
39
- activesupport (= 5.0.1)
40
- arel (~> 7.0)
41
- activesupport (5.0.1)
35
+ activemodel (5.1.3)
36
+ activesupport (= 5.1.3)
37
+ activerecord (5.1.3)
38
+ activemodel (= 5.1.3)
39
+ activesupport (= 5.1.3)
40
+ arel (~> 8.0)
41
+ activesupport (5.1.3)
42
42
  concurrent-ruby (~> 1.0, >= 1.0.2)
43
43
  i18n (~> 0.7)
44
44
  minitest (~> 5.1)
45
45
  tzinfo (~> 1.1)
46
- addressable (2.5.0)
46
+ addressable (2.5.1)
47
47
  public_suffix (~> 2.0, >= 2.0.2)
48
- arel (7.1.4)
49
- bson (3.2.6)
48
+ arel (8.0.0)
49
+ bson (3.2.7)
50
50
  builder (3.2.3)
51
51
  carrierwave (0.9.0)
52
52
  activemodel (>= 3.2.0)
53
53
  activesupport (>= 3.2.0)
54
54
  json (>= 1.7)
55
- climate_control (0.1.0)
55
+ climate_control (0.2.0)
56
56
  cocaine (0.5.8)
57
57
  climate_control (>= 0.0.3, < 1.0)
58
58
  coderay (1.1.1)
59
- concurrent-ruby (1.0.4)
59
+ concurrent-ruby (1.0.5)
60
60
  connection_pool (2.2.1)
61
61
  crass (1.0.2)
62
- database_cleaner (1.5.3)
62
+ database_cleaner (1.6.1)
63
63
  diff-lcs (1.3)
64
64
  docile (1.1.5)
65
- erubis (2.7.0)
65
+ erubi (1.6.1)
66
66
  factory_girl (4.8.0)
67
67
  activesupport (>= 3.0.0)
68
- geocoder (1.4.3)
68
+ geocoder (1.4.4)
69
69
  glebtv-carrierwave-mongoid (0.7.0)
70
70
  carrierwave (~> 0.9.0)
71
71
  mongoid (~> 4.0.0.alpha1)
72
72
  glebtv-mongoid-paperclip (0.5.0)
73
73
  mongoid (>= 3.0, < 6.1)
74
74
  paperclip (~> 5.1.0)
75
- globalid (0.3.7)
76
- activesupport (>= 4.1.0)
77
- i18n (0.8.0)
78
- json (2.0.3)
75
+ globalid (0.4.0)
76
+ activesupport (>= 4.2.0)
77
+ i18n (0.8.6)
78
+ json (2.1.0)
79
79
  loofah (2.0.3)
80
80
  nokogiri (>= 1.5.9)
81
- mail (2.6.4)
81
+ mail (2.6.6)
82
82
  mime-types (>= 1.16, < 4)
83
83
  method_source (0.8.2)
84
84
  mime-types (3.1)
85
85
  mime-types-data (~> 3.2015)
86
86
  mime-types-data (3.2016.0521)
87
87
  mimemagic (0.3.2)
88
- mini_portile2 (2.1.0)
89
- minitest (5.10.1)
88
+ mini_portile2 (2.2.0)
89
+ minitest (5.10.3)
90
90
  mongoid (4.0.0.beta2)
91
91
  activemodel (>= 4.0.0)
92
92
  moped (~> 2.0.beta6)
@@ -100,13 +100,13 @@ GEM
100
100
  bson (~> 3.0)
101
101
  connection_pool (~> 2.0)
102
102
  optionable (~> 0.2.0)
103
- nio4r (1.2.1)
104
- nokogiri (1.7.0.1)
105
- mini_portile2 (~> 2.1.0)
106
- nokogumbo (1.4.10)
103
+ nio4r (2.1.0)
104
+ nokogiri (1.8.0)
105
+ mini_portile2 (~> 2.2.0)
106
+ nokogumbo (1.4.13)
107
107
  nokogiri
108
108
  optionable (0.2.0)
109
- origin (2.3.0)
109
+ origin (2.3.1)
110
110
  paperclip (5.1.0)
111
111
  activemodel (>= 4.2.0)
112
112
  activesupport (>= 4.2.0)
@@ -118,57 +118,57 @@ GEM
118
118
  method_source (~> 0.8.1)
119
119
  slop (~> 3.4)
120
120
  public_suffix (2.0.5)
121
- rack (2.0.1)
121
+ rack (2.0.3)
122
122
  rack-test (0.6.3)
123
123
  rack (>= 1.0)
124
- rails (5.0.1)
125
- actioncable (= 5.0.1)
126
- actionmailer (= 5.0.1)
127
- actionpack (= 5.0.1)
128
- actionview (= 5.0.1)
129
- activejob (= 5.0.1)
130
- activemodel (= 5.0.1)
131
- activerecord (= 5.0.1)
132
- activesupport (= 5.0.1)
133
- bundler (>= 1.3.0, < 2.0)
134
- railties (= 5.0.1)
124
+ rails (5.1.3)
125
+ actioncable (= 5.1.3)
126
+ actionmailer (= 5.1.3)
127
+ actionpack (= 5.1.3)
128
+ actionview (= 5.1.3)
129
+ activejob (= 5.1.3)
130
+ activemodel (= 5.1.3)
131
+ activerecord (= 5.1.3)
132
+ activesupport (= 5.1.3)
133
+ bundler (>= 1.3.0)
134
+ railties (= 5.1.3)
135
135
  sprockets-rails (>= 2.0.0)
136
- rails-dom-testing (2.0.2)
137
- activesupport (>= 4.2.0, < 6.0)
138
- nokogiri (~> 1.6)
136
+ rails-dom-testing (2.0.3)
137
+ activesupport (>= 4.2.0)
138
+ nokogiri (>= 1.6)
139
139
  rails-html-sanitizer (1.0.3)
140
140
  loofah (~> 2.0)
141
- railties (5.0.1)
142
- actionpack (= 5.0.1)
143
- activesupport (= 5.0.1)
141
+ railties (5.1.3)
142
+ actionpack (= 5.1.3)
143
+ activesupport (= 5.1.3)
144
144
  method_source
145
145
  rake (>= 0.8.7)
146
146
  thor (>= 0.18.1, < 2.0)
147
147
  rake (12.0.0)
148
- rspec (3.5.0)
149
- rspec-core (~> 3.5.0)
150
- rspec-expectations (~> 3.5.0)
151
- rspec-mocks (~> 3.5.0)
152
- rspec-core (3.5.4)
153
- rspec-support (~> 3.5.0)
154
- rspec-expectations (3.5.0)
148
+ rspec (3.6.0)
149
+ rspec-core (~> 3.6.0)
150
+ rspec-expectations (~> 3.6.0)
151
+ rspec-mocks (~> 3.6.0)
152
+ rspec-core (3.6.0)
153
+ rspec-support (~> 3.6.0)
154
+ rspec-expectations (3.6.0)
155
155
  diff-lcs (>= 1.2.0, < 2.0)
156
- rspec-support (~> 3.5.0)
157
- rspec-mocks (3.5.0)
156
+ rspec-support (~> 3.6.0)
157
+ rspec-mocks (3.6.0)
158
158
  diff-lcs (>= 1.2.0, < 2.0)
159
- rspec-support (~> 3.5.0)
160
- rspec-support (3.5.0)
161
- russian_phone (0.5.3)
159
+ rspec-support (~> 3.6.0)
160
+ rspec-support (3.6.0)
161
+ russian_phone (0.6.0)
162
162
  safe_yaml (1.0.4)
163
- sanitize (4.4.0)
163
+ sanitize (4.5.0)
164
164
  crass (~> 1.0.2)
165
165
  nokogiri (>= 1.4.4)
166
166
  nokogumbo (~> 1.4.1)
167
- simplecov (0.13.0)
167
+ simplecov (0.14.1)
168
168
  docile (~> 1.1.0)
169
169
  json (>= 1.8, < 3)
170
170
  simplecov-html (~> 0.10.0)
171
- simplecov-html (0.10.0)
171
+ simplecov-html (0.10.1)
172
172
  slop (3.6.0)
173
173
  sprockets (3.7.1)
174
174
  concurrent-ruby (~> 1.0)
@@ -178,8 +178,8 @@ GEM
178
178
  activesupport (>= 4.0)
179
179
  sprockets (>= 3.0.0)
180
180
  thor (0.19.4)
181
- thread_safe (0.3.5)
182
- tzinfo (1.2.2)
181
+ thread_safe (0.3.6)
182
+ tzinfo (1.2.3)
183
183
  thread_safe (~> 0.1)
184
184
  validates_email_format_of (1.6.3)
185
185
  i18n
data/README.md CHANGED
@@ -113,6 +113,8 @@ Supported types:
113
113
  domain (requires addressable)
114
114
  js (requires codemirror)
115
115
  css (requires codemirror)
116
+ array(array of inputs)
117
+ hash(array of inputs 'key-value')
116
118
 
117
119
 
118
120
  Strings and html support following replacement patterns:
@@ -0,0 +1,43 @@
1
+ $(document).on "click", "#edit_rails_admin_settings_setting .raw_array_field .rails_admin_settings_array_element_add_link", (e)->
2
+ e.preventDefault()
3
+ link = $(e.currentTarget)
4
+ link_parent = link.parent()
5
+ link_parent.before(link.data('template'))
6
+ link_parent.prev().find('input:first').focus().select().trigger('change')
7
+ return false
8
+
9
+
10
+ $(document).on 'click', '#edit_rails_admin_settings_setting .raw_array_field .rails_admin_settings_array_element_delete_link', (e)->
11
+ e.preventDefault()
12
+ hidden_field = $(e.currentTarget).closest(".raw_array_field").find("[type='hidden']")
13
+ $(e.currentTarget).parent().remove()
14
+ hidden_field.trigger('change')
15
+ return false
16
+
17
+
18
+ $(document).on 'click', '#edit_rails_admin_settings_setting .raw_array_field .rails_admin_settings_array_element_move_link', (e)->
19
+ e.preventDefault()
20
+ link = $(e.currentTarget)
21
+ array_element_block = link.parent()
22
+ if link.hasClass("up")
23
+ prev = array_element_block.prev(".rails_admin_settings_array_element_block")
24
+ array_element_block.insertBefore(prev) if prev.length > 0
25
+ if link.hasClass("down")
26
+ next = array_element_block.next(".rails_admin_settings_array_element_block")
27
+ array_element_block.insertAfter(next) if next.length > 0
28
+ return false
29
+
30
+
31
+
32
+ $(document).on "change", "#edit_rails_admin_settings_setting .raw_array_field :input", (e)->
33
+ field_block = $(e.currentTarget).closest(".raw_array_field")
34
+ hidden_field = field_block.find("[type='hidden']")
35
+ if field_block.find(":input:not([type='hidden'])").serializeArray().length == 0
36
+ hidden_field.prop('name', hidden_field.data('name')) if hidden_field.data('name')
37
+ else
38
+ hidden_field.data('name', hidden_field.prop('name')) if hidden_field.prop('name')
39
+ hidden_field.prop('name', '')
40
+
41
+
42
+ $(document).on "rails_admin.dom_ready", (e)->
43
+ $("#edit_rails_admin_settings_setting .raw_array_field").find(":input[type='hidden']").trigger('change')
@@ -0,0 +1,32 @@
1
+ $(document).on "click", "#edit_rails_admin_settings_setting .raw_hash_field .rails_admin_settings_hash_element_add_link", (e)->
2
+ e.preventDefault()
3
+ link = $(e.currentTarget)
4
+ link_parent = link.parent()
5
+ link_parent.before(link.data('template'))
6
+ $("#edit_rails_admin_settings_setting .raw_hash_field .rails_admin_settings_hash_element_block input:last").blur()
7
+ return false
8
+
9
+
10
+ $(document).on 'click', '#edit_rails_admin_settings_setting .raw_hash_field .rails_admin_settings_hash_element_delete_link', (e)->
11
+ e.preventDefault()
12
+ $(e.currentTarget).parent().remove()
13
+ return false
14
+
15
+ $(document).on 'blur', '#edit_rails_admin_settings_setting .raw_hash_field .rails_admin_settings_hash_element_key_field', (e)->
16
+ e.preventDefault()
17
+ input = $(e.currentTarget).siblings('input')
18
+ old_id = input.prop('id')
19
+ old_name = input.prop('name')
20
+ new_name = e.currentTarget.value
21
+ reg_for_id = /\[[^\[\]]+\]$/i
22
+ reg_for_name = /\[[^\[\]]+\]\]$/i
23
+ input.prop('id', old_id.replace(reg_for_id, "[" + new_name + "]"))
24
+ input.prop('name', old_name.replace(reg_for_name, "[" + new_name + "]]"))
25
+ return false
26
+
27
+
28
+ $(document).on 'blur', '#edit_rails_admin_settings_setting .raw_hash_field .rails_admin_settings_hash_element_block input', (e)->
29
+ fields_block = $(e.currentTarget).closest(".controls")
30
+ fields_block.find('.value_field').each ->
31
+ $(this).parent().removeClass('duplicate')
32
+ fields_block.find('.value_field').not($(this)).filter("[name='" + this.name + "']").parent().addClass('duplicate')
@@ -0,0 +1,5 @@
1
+ #edit_rails_admin_settings_setting
2
+ .raw_hash_field
3
+ .rails_admin_settings_hash_element_block
4
+ &.duplicate
5
+ background-color: rgb(255, 107, 107)
@@ -71,12 +71,12 @@ module RailsAdminSettings
71
71
  # t = {_all: 'Все'}
72
72
  if ::Settings.table_exists?
73
73
  ::RailsAdminSettings::Setting.pluck(:ns).uniq.each do |c|
74
- s = "ns_#{c.gsub('-', '_')}".to_sym
75
- scope s, -> { where(ns: c) }
76
- # t[s] = c
77
- end
78
- end
79
- # I18n.backend.store_translations(:ru, {admin: {scopes: {'rails_admin_settings/setting': t}}})
74
+ s = "ns_#{c.gsub('-', '_')}".to_sym
75
+ scope s, -> { where(ns: c) }
76
+ # t[s] = c
77
+ end
78
+ end
79
+ # I18n.backend.store_translations(:ru, {admin: {scopes: {'rails_admin_settings/setting': t}}})
80
80
 
81
81
  if Object.const_defined?('RailsAdmin')
82
82
  include RailsAdminSettings::RailsAdminConfig
@@ -102,3 +102,32 @@
102
102
  }
103
103
 
104
104
  = form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'codemirror', options: js_data.to_json }).reverse_merge({ value: field.form_value })
105
+
106
+
107
+ - elsif @object.type == 'array'
108
+ = javascript_include_tag 'rails_admin_settings/array'
109
+
110
+ = form.hidden_field field.method_name, value: "", multiple: true
111
+ - (field.value || []).each do |val|
112
+ = render partial: 'rails_admin/main/rails_admin_settings/array/element', locals: {form: form, field: field, val: val}
113
+
114
+ - _template = capture do
115
+ = render partial: 'rails_admin/main/rails_admin_settings/array/element', locals: {form: form, field: field, val: ""}
116
+ %p
117
+ = link_to "добавить", "#", class: "rails_admin_settings_array_element_add_link", data: {template: _template.html_safe}
118
+
119
+
120
+ - elsif @object.type == 'hash'
121
+ = javascript_include_tag 'rails_admin_settings/hash'
122
+ = stylesheet_link_tag 'rails_admin_settings/hash'
123
+
124
+ - (field.value || {}).each_pair do |name, val|
125
+ = render partial: 'rails_admin/main/rails_admin_settings/hash/element', locals: {form: form, field: field, name: name, val: val}
126
+
127
+ - _template = capture do
128
+ - name, val = "new", ""
129
+ = render partial: 'rails_admin/main/rails_admin_settings/hash/element', locals: {form: form, field: field, name: name, val: val}
130
+ %p
131
+ = link_to "добавить", "#", class: "rails_admin_settings_hash_element_add_link", data: {template: _template.html_safe}
132
+ / = " | "
133
+ / = link_to "показать дубликаты", "#", class: "rails_admin_settings_hash_element_duplicate_trigger", data: {text: "скрыть дубликаты"}
@@ -0,0 +1,8 @@
1
+ .rails_admin_settings_array_element_block
2
+ = form.text_field field.method_name, value: val, multiple: true
3
+ %span= " "
4
+ = link_to "(удалить)", "#", class: "rails_admin_settings_array_element_delete_link", tabindex: -1
5
+ %span= " "
6
+ = link_to "/\\", "#", class: "rails_admin_settings_array_element_move_link array_element_move_up_link up", tabindex: -1
7
+ %span= " "
8
+ = link_to "\\/", "#", class: "rails_admin_settings_array_element_move_link array_element_move_down_link down", tabindex: -1
@@ -0,0 +1,6 @@
1
+ .rails_admin_settings_hash_element_block
2
+ = form.text_field nil, value: name, class: 'rails_admin_settings_hash_element_key_field', name: ""
3
+ %span= ": "
4
+ = form.text_field "#{field.method_name}[#{name}]", value: val, class: 'value_field'
5
+ %span= " #{name} "
6
+ = link_to "(удалить)", "#", class: "rails_admin_settings_hash_element_delete_link", tabindex: -1
@@ -20,9 +20,10 @@ en:
20
20
  name: Name
21
21
  key: Key
22
22
  raw: Value
23
+ raw_array: Value
24
+ raw_hash: Value
23
25
  type: Type
24
26
  kind: Type
25
27
  label: Label
26
28
  activerecord:
27
29
  <<: *mongoid
28
-
@@ -20,9 +20,10 @@ ru:
20
20
  name: Название
21
21
  key: Ключ
22
22
  raw: Значение
23
+ raw_array: Значение
24
+ raw_hash: Значение
23
25
  type: Тип
24
26
  kind: Тип
25
27
  label: Подпись
26
28
  activerecord:
27
29
  <<: *mongoid
28
-
@@ -4,6 +4,13 @@ module RailsAdminSettings
4
4
  require File.expand_path('../tasks', __FILE__)
5
5
  end
6
6
 
7
+
8
+ initializer "RailsAdminSettings precompile hook", group: :all do |app|
9
+ app.config.assets.precompile += %w(rails_admin_settings/array.js)
10
+ app.config.assets.precompile += %w(rails_admin_settings/hash.js rails_admin_settings/hash.css)
11
+ end
12
+
13
+
7
14
  initializer 'RailsAdminSettings Install after_action' do |app|
8
15
  require File.dirname(__FILE__) + '/../../app/models/rails_admin_settings/setting.rb'
9
16
 
@@ -20,7 +20,10 @@ module RailsAdminSettings
20
20
  'color',
21
21
 
22
22
  'js',
23
- 'css'
23
+ 'css',
24
+
25
+ 'array',
26
+ 'hash'
24
27
  ].freeze
25
28
  end
26
29
 
@@ -11,6 +11,8 @@ module RailsAdminSettings
11
11
  field :ns, type: String, default: 'main'
12
12
  field :key, type: String
13
13
  field :raw, type: String
14
+ field :raw_array, type: Array
15
+ field :raw_hash, type: Hash
14
16
  field :label, type: String
15
17
  field :loadable, type: Boolean, default: true
16
18
  scope :loadable, -> {
@@ -239,10 +239,19 @@ module RailsAdminSettings
239
239
  end
240
240
 
241
241
  def write_to_database(key, options)
242
+ options[:kind] = options[:kind].to_s if options[:kind]
242
243
  is_file = !options[:kind].nil? && (options[:kind] == 'image' || options[:kind] == 'file')
244
+ is_array = !options[:kind].nil? && (options[:kind] == 'array')
245
+ is_hash = !options[:kind].nil? && (options[:kind] == 'hash')
243
246
  if is_file
244
247
  options[:raw] = ''
245
248
  file = options[:value]
249
+ elsif is_array
250
+ options[:raw] = ''
251
+ options[:raw_array] = options[:value] if options[:value]
252
+ elsif is_hash
253
+ options[:raw] = ''
254
+ options[:raw_hash] = options[:value] if options[:value]
246
255
  else
247
256
  options[:raw] = options[:value] if options[:value]
248
257
  end
@@ -280,6 +289,8 @@ module RailsAdminSettings
280
289
  opts = options.dup
281
290
  if options[:overwrite] == false && !@settings[key].value.blank?
282
291
  opts.delete(:raw)
292
+ opts.delete(:raw_array)
293
+ opts.delete(:raw_hash)
283
294
  opts.delete(:value)
284
295
  opts.delete(:enabled)
285
296
  end
@@ -24,6 +24,13 @@ module RailsAdminSettings
24
24
  alias_method :upload_type?, :upload_kind?
25
25
  alias_method :html_type?, :html_kind?
26
26
 
27
+ def array_kind?
28
+ ['array'].include? kind
29
+ end
30
+ def hash_kind?
31
+ ['hash'].include? kind
32
+ end
33
+
27
34
  def value
28
35
  if upload_kind?
29
36
  if file_kind?
@@ -31,6 +38,10 @@ module RailsAdminSettings
31
38
  else
32
39
  nil
33
40
  end
41
+ elsif array_kind?
42
+ raw_array
43
+ elsif hash_kind?
44
+ raw_hash
34
45
  elsif raw.blank? || disabled?
35
46
  default_value
36
47
  else
@@ -41,6 +52,10 @@ module RailsAdminSettings
41
52
  def blank?
42
53
  if file_kind?
43
54
  file.url.nil?
55
+ elsif array_kind?
56
+ raw_array.blank?
57
+ elsif hash_kind?
58
+ raw_hash.blank?
44
59
  elsif raw.blank? || disabled?
45
60
  true
46
61
  else
@@ -51,6 +66,10 @@ module RailsAdminSettings
51
66
  def to_s
52
67
  if yaml_kind? || phone_kind? || integer_kind?
53
68
  raw
69
+ elsif array_kind?
70
+ raw_array.join(", ")
71
+ elsif hash_kind?
72
+ raw_hash.to_json
54
73
  else
55
74
  value
56
75
  end
@@ -82,13 +101,17 @@ module RailsAdminSettings
82
101
  end
83
102
  elsif phones_kind?
84
103
  []
104
+ elsif array_kind?
105
+ []
106
+ elsif hash_kind?
107
+ {}
85
108
  else
86
109
  nil
87
110
  end
88
111
  end
89
112
 
90
113
  def default_serializable_value
91
- if phones_kind?
114
+ if phones_kind? or array_kind? or hash_kind?
92
115
  ''
93
116
  elsif boolean_type?
94
117
  'false'
@@ -146,6 +169,10 @@ module RailsAdminSettings
146
169
  load_phones
147
170
  elsif file_kind?
148
171
  file.url
172
+ elsif array_kind?
173
+ raw_array
174
+ elsif hash_kind?
175
+ raw_hash
149
176
  else
150
177
  puts "[rails_admin_settings] Unknown field kind: #{kind}".freeze
151
178
  nil
@@ -41,6 +41,18 @@ module RailsAdminSettings
41
41
  end
42
42
  end
43
43
  end
44
+ field :raw_array do
45
+ searchable true
46
+ pretty_value do
47
+ bindings[:object].raw_array.join("<br>").html_safe
48
+ end
49
+ end
50
+ field :raw_hash do
51
+ searchable true
52
+ pretty_value do
53
+ "<pre>#{JSON.pretty_generate(bindings[:object].raw_hash)}</pre>".html_safe
54
+ end
55
+ end
44
56
  field :cache_keys_str, :text do
45
57
  searchable true
46
58
  end
@@ -72,7 +84,25 @@ module RailsAdminSettings
72
84
  field :raw do
73
85
  partial "setting_value".freeze
74
86
  visible do
75
- !bindings[:object].upload_kind?
87
+ !bindings[:object].upload_kind? and !bindings[:object].array_kind? and !bindings[:object].hash_kind?
88
+ end
89
+ end
90
+ field :raw_array do
91
+ partial "setting_value".freeze
92
+ pretty_value do
93
+ bindings[:object].raw_array.map(&:to_s).join("<br>").html_safe
94
+ end
95
+ visible do
96
+ bindings[:object].array_kind?
97
+ end
98
+ end
99
+ field :raw_hash do
100
+ partial "setting_value".freeze
101
+ pretty_value do
102
+ "<pre>#{JSON.pretty_generate(bindings[:object].raw_hash)}</pre>".html_safe
103
+ end
104
+ visible do
105
+ bindings[:object].hash_kind?
76
106
  end
77
107
  end
78
108
  if Settings.file_uploads_supported
@@ -1,3 +1,3 @@
1
1
  module RailsAdminSettings
2
- VERSION = "1.2.2.1".freeze
2
+ VERSION = "1.2.3".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ack_rails_admin_settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-17 00:00:00.000000000 Z
12
+ date: 2017-08-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
@@ -288,8 +288,13 @@ files:
288
288
  - LICENSE.txt
289
289
  - README.md
290
290
  - Rakefile
291
+ - app/assets/javascripts/rails_admin_settings/array.coffee
292
+ - app/assets/javascripts/rails_admin_settings/hash.coffee
293
+ - app/assets/stylesheets/rails_admin_settings/hash.sass
291
294
  - app/models/rails_admin_settings/setting.rb
292
295
  - app/views/rails_admin/main/_setting_value.html.haml
296
+ - app/views/rails_admin/main/rails_admin_settings/array/_element.html.haml
297
+ - app/views/rails_admin/main/rails_admin_settings/hash/_element.html.haml
293
298
  - config/locales/en.yml
294
299
  - config/locales/ru.yml
295
300
  - gemfiles/mongoid-3.1.gemfile