activeadmin_dynamic_fields 0.2.2 → 0.2.6
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 +5 -5
- data/.rubocop.yml +73 -0
- data/README.md +8 -6
- data/Rakefile +2 -2
- data/activeadmin_dynamic_fields.gemspec +4 -2
- data/app/assets/javascripts/activeadmin/dynamic_fields.js +111 -114
- data/lib/activeadmin/dynamic_fields.rb +2 -0
- data/lib/activeadmin/dynamic_fields/engine.rb +28 -8
- data/lib/activeadmin/dynamic_fields/version.rb +3 -1
- data/lib/activeadmin_dynamic_fields.rb +2 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a0ed5077c7c98c62def46fd92bc4e832c97239af6c5549feb26c9c0190dd9f4c
|
4
|
+
data.tar.gz: 6c874a1265046e090b1e1528de0f030a06fc4cf916d1f1625b174323c90be756
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abb89d40dd388777bad8ec10264358993e3d70c07d45b5ab4720a7ac4bab0caa9ff0032bc312eb9a744e84cb0923dead550a9e9e61dc822846dce5a998ae3c62
|
7
|
+
data.tar.gz: adfea763fa7d6ab978a3048d55e0f6a9ab14c5fc2ac743603176512f477fc822524126ca936d816aa3285a87c3c1ec46aae0076f7513e669552bf51cbd2a4a98
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
|
4
|
+
Rails:
|
5
|
+
Enabled: true
|
6
|
+
|
7
|
+
AllCops:
|
8
|
+
TargetRubyVersion: 2.3.8
|
9
|
+
TargetRailsVersion: 5.2
|
10
|
+
Exclude:
|
11
|
+
- db/schema.rb
|
12
|
+
- bin/*
|
13
|
+
- node_modules/**/*
|
14
|
+
# Temporary files
|
15
|
+
- tmp/**/*
|
16
|
+
|
17
|
+
Rails/InverseOf:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Style/Documentation:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
Metrics/ClassLength:
|
24
|
+
# Default value is 100
|
25
|
+
Max: 150
|
26
|
+
|
27
|
+
Metrics/LineLength:
|
28
|
+
# Default is 80
|
29
|
+
Max: 120
|
30
|
+
|
31
|
+
Metrics/ModuleLength:
|
32
|
+
# Default is 100
|
33
|
+
Max: 150
|
34
|
+
|
35
|
+
Metrics/ParameterLists:
|
36
|
+
# Default is 5
|
37
|
+
Max: 6
|
38
|
+
|
39
|
+
RSpec/ExampleLength:
|
40
|
+
# Default is 10
|
41
|
+
Max: 20
|
42
|
+
|
43
|
+
Style/FrozenStringLiteralComment:
|
44
|
+
# Deface DOES edit strings in place
|
45
|
+
Exclude:
|
46
|
+
- 'app/overrides/**/*'
|
47
|
+
|
48
|
+
RSpec/MultipleExpectations:
|
49
|
+
# Default is 3
|
50
|
+
Max: 5
|
51
|
+
|
52
|
+
RSpec/NestedGroups:
|
53
|
+
# Default is 3
|
54
|
+
Max: 6
|
55
|
+
|
56
|
+
Metrics/AbcSize:
|
57
|
+
Max: 25
|
58
|
+
|
59
|
+
Metrics/BlockLength:
|
60
|
+
# This value double the rubocop default
|
61
|
+
Max: 50
|
62
|
+
|
63
|
+
Metrics/CyclomaticComplexity:
|
64
|
+
# This value double the rubocop default
|
65
|
+
Max: 12
|
66
|
+
|
67
|
+
Metrics/MethodLength:
|
68
|
+
# This value double the rubocop default
|
69
|
+
Max: 20
|
70
|
+
|
71
|
+
Metrics/PerceivedComplexity:
|
72
|
+
# Default is 7
|
73
|
+
Max: 10
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Features:
|
|
9
9
|
- inline field editing
|
10
10
|
- create links to load some content in a dialog
|
11
11
|
|
12
|
-
The easiest way to show how this plugin works is looking the examples [below](#examples
|
12
|
+
The easiest way to show how this plugin works is looking the examples [below](#examples).
|
13
13
|
|
14
14
|
## Install
|
15
15
|
|
@@ -46,22 +46,22 @@ Options are passed to fields using *input_html* parameter as *data* attributes:
|
|
46
46
|
|
47
47
|
### Dynamic fields examples
|
48
48
|
|
49
|
-
- A checkbox that hides other fields if
|
49
|
+
- A checkbox that hides other fields if is checked (ex. model *Article*):
|
50
50
|
|
51
51
|
```rb
|
52
52
|
form do |f|
|
53
53
|
f.inputs 'Article' do
|
54
|
-
f.input :published, input_html: { data: { if: '
|
54
|
+
f.input :published, input_html: { data: { if: 'checked', action: 'hide', target: '.grp1' } }
|
55
55
|
f.input :online_date, wrapper_html: { class: 'grp1' }
|
56
|
-
f.input :
|
56
|
+
f.input :draft_notes, wrapper_html: { class: 'grp1' }
|
57
57
|
end
|
58
58
|
f.actions
|
59
59
|
end
|
60
60
|
```
|
61
61
|
|
62
|
-
- Add 3 classes (*first*, *second*, *third*) if a checkbox is
|
62
|
+
- Add 3 classes (*first*, *second*, *third*) if a checkbox is not checked:
|
63
63
|
|
64
|
-
`f.input :published, input_html: { data: { if: '
|
64
|
+
`f.input :published, input_html: { data: { if: 'not_checked', action: 'addClass first second third', target: '.grp1' } }`
|
65
65
|
|
66
66
|
- Set another field value if a string field is blank:
|
67
67
|
|
@@ -184,6 +184,8 @@ The link url is loaded via AJAX before opening the dialog.
|
|
184
184
|
|
185
185
|
If you use this component just star it. A developer is more motivated to improve a project when there is some interest.
|
186
186
|
|
187
|
+
Take a look at [other ActiveAdmin components](https://github.com/blocknotes?utf8=✓&tab=repositories&q=activeadmin&type=source) that I made if you are curious.
|
188
|
+
|
187
189
|
## Contributors
|
188
190
|
|
189
191
|
- [Mattia Roccoberton](http://blocknot.es) - creator, maintainer
|
data/Rakefile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'activeadmin/dynamic_fields/version'
|
4
6
|
|
@@ -15,5 +17,5 @@ Gem::Specification.new do |spec|
|
|
15
17
|
spec.files = `git ls-files -z`.split("\x0")
|
16
18
|
spec.require_paths = ['lib']
|
17
19
|
|
18
|
-
spec.add_runtime_dependency 'activeadmin', '
|
20
|
+
spec.add_runtime_dependency 'activeadmin', '>= 1.0'
|
19
21
|
end
|
@@ -1,117 +1,117 @@
|
|
1
1
|
// Evaluate a condition
|
2
|
-
function dfEvalCondition(
|
3
|
-
if(
|
4
|
-
if(
|
5
|
-
else console.log(
|
2
|
+
function dfEvalCondition(el, args, on_change) {
|
3
|
+
if(args.fn) {
|
4
|
+
if(args.fn && window[args.fn]) return !window[args.fn](el);
|
5
|
+
else console.log('Warning - activeadmin_dynamic_fields: ' + args.fn + '() not available [1]');
|
6
6
|
}
|
7
|
-
else if(
|
7
|
+
else if(args.if == 'checked') {
|
8
8
|
return el.is(':checked');
|
9
9
|
}
|
10
|
-
else if(
|
10
|
+
else if(args.if == 'not_checked') {
|
11
11
|
return !el.is(':checked');
|
12
12
|
}
|
13
|
-
else if(
|
13
|
+
else if(args.if == 'blank') {
|
14
14
|
return el.val().length === 0 || !el.val().trim();
|
15
15
|
}
|
16
|
-
else if(
|
16
|
+
else if(args.if == 'not_blank') {
|
17
17
|
return el.val().length !== 0 && el.val().trim();
|
18
18
|
}
|
19
|
-
else if(
|
19
|
+
else if(args.if == 'changed') {
|
20
20
|
return on_change;
|
21
21
|
}
|
22
|
-
else if(
|
22
|
+
else if(args.eq) {
|
23
23
|
return el.val() == args.eq;
|
24
24
|
}
|
25
|
-
else if(
|
25
|
+
else if(args.not) {
|
26
26
|
return el.val() != args.not;
|
27
27
|
}
|
28
28
|
return undefined;
|
29
29
|
}
|
30
30
|
|
31
31
|
// Prepare a field
|
32
|
-
function dfSetupField(
|
33
|
-
var action = el.data(
|
32
|
+
function dfSetupField(el) {
|
33
|
+
var action = el.data('action');
|
34
34
|
var target, args = {};
|
35
|
-
args.if = el.data(
|
36
|
-
args.eq = el.data(
|
37
|
-
args.not = el.data(
|
38
|
-
args.fn = el.data(
|
39
|
-
if(
|
40
|
-
else if(
|
41
|
-
if(
|
42
|
-
if(
|
35
|
+
args.if = el.data('if');
|
36
|
+
args.eq = el.data('eq');
|
37
|
+
args.not = el.data('not');
|
38
|
+
args.fn = el.data('function');
|
39
|
+
if(el.data('target')) target = el.closest('fieldset').find(el.data('target')); // closest find for has many associations
|
40
|
+
else if(el.data('gtarget')) target = $(el.data('gtarget'));
|
41
|
+
if(action == 'hide') {
|
42
|
+
if(dfEvalCondition(el, args, false)) target.hide();
|
43
43
|
else target.show();
|
44
|
-
el.on(
|
45
|
-
if(
|
44
|
+
el.on('change', function(event) {
|
45
|
+
if(dfEvalCondition($(this), args, true)) target.hide();
|
46
46
|
else target.show();
|
47
47
|
});
|
48
48
|
}
|
49
|
-
else if(
|
50
|
-
if(
|
49
|
+
else if(action == 'slide') {
|
50
|
+
if(dfEvalCondition(el, args, false)) target.slideDown();
|
51
51
|
else target.slideUp();
|
52
|
-
el.on(
|
53
|
-
if(
|
52
|
+
el.on('change', function(event) {
|
53
|
+
if(dfEvalCondition($(this), args, true)) target.slideDown();
|
54
54
|
else target.slideUp();
|
55
55
|
});
|
56
56
|
}
|
57
|
-
else if(
|
58
|
-
if(
|
57
|
+
else if(action == 'fade') {
|
58
|
+
if(dfEvalCondition(el, args, false)) target.fadeIn();
|
59
59
|
else target.fadeOut();
|
60
|
-
el.on(
|
61
|
-
if(
|
60
|
+
el.on('change', function(event) {
|
61
|
+
if(dfEvalCondition($(this), args, true)) target.fadeIn();
|
62
62
|
else target.fadeOut();
|
63
63
|
});
|
64
64
|
}
|
65
|
-
else if(
|
66
|
-
var val = action.substr(
|
67
|
-
if(
|
68
|
-
el.on(
|
69
|
-
if(
|
65
|
+
else if(action.substr(0, 8) == 'setValue') {
|
66
|
+
var val = action.substr(8).trim();
|
67
|
+
if(dfEvalCondition(el, args, false)) dfSetValue(target, val);
|
68
|
+
el.on('change', function(event) {
|
69
|
+
if(dfEvalCondition($(this), args, true)) dfSetValue(target, val);
|
70
70
|
});
|
71
71
|
}
|
72
|
-
else if(
|
73
|
-
var cb = action.substr(
|
74
|
-
if(
|
75
|
-
if(
|
76
|
-
el.on(
|
77
|
-
if(
|
72
|
+
else if(action.substr(0, 8) == 'callback') {
|
73
|
+
var cb = action.substr(8).trim();
|
74
|
+
if(cb && window[cb]) {
|
75
|
+
if(dfEvalCondition(el, args, false)) window[cb](el.data('args'));
|
76
|
+
el.on('change', function(event) {
|
77
|
+
if(dfEvalCondition($(this), args, true)) window[cb](el.data('args'));
|
78
78
|
});
|
79
79
|
}
|
80
|
-
else console.log(
|
81
|
-
}
|
82
|
-
else if(
|
83
|
-
var classes = action.substr(
|
84
|
-
if(
|
85
|
-
else target.addClass(
|
86
|
-
el.on(
|
87
|
-
if(
|
88
|
-
else target.addClass(
|
80
|
+
else console.log('Warning - activeadmin_dynamic_fields: ' + cb + '() not available [2]');
|
81
|
+
}
|
82
|
+
else if(action.substr(0, 8) == 'addClass') {
|
83
|
+
var classes = action.substr(8).trim();
|
84
|
+
if(dfEvalCondition(el, args, false)) target.removeClass(classes);
|
85
|
+
else target.addClass(classes);
|
86
|
+
el.on('change', function(event) {
|
87
|
+
if(dfEvalCondition($(this), args, true)) target.removeClass(classes);
|
88
|
+
else target.addClass(classes);
|
89
89
|
});
|
90
90
|
}
|
91
|
-
else if(
|
92
|
-
dfEvalCondition(
|
93
|
-
el.on(
|
94
|
-
dfEvalCondition(
|
91
|
+
else if(args.fn) { // function without action
|
92
|
+
dfEvalCondition(el, args, false);
|
93
|
+
el.on('change', function(event) {
|
94
|
+
dfEvalCondition(el, args, true);
|
95
95
|
});
|
96
96
|
}
|
97
97
|
}
|
98
98
|
|
99
99
|
// Set the value of an element
|
100
|
-
function dfSetValue(
|
101
|
-
if(
|
100
|
+
function dfSetValue(el, val) {
|
101
|
+
if(el.attr('type') != 'checkbox') el.val(val);
|
102
102
|
else el.prop('checked', val == '1');
|
103
|
-
el.trigger(
|
103
|
+
el.trigger('change');
|
104
104
|
}
|
105
105
|
|
106
106
|
// Inline update - must be called binded on the editing element
|
107
107
|
function dfUpdateField() {
|
108
|
-
if(
|
109
|
-
$(this).data(
|
108
|
+
if($(this).data('loading') != '1') {
|
109
|
+
$(this).data('loading', '1');
|
110
110
|
var _this = $(this);
|
111
|
-
var type = $(this).data(
|
111
|
+
var type = $(this).data('field-type');
|
112
112
|
var new_value;
|
113
|
-
if(
|
114
|
-
else if(
|
113
|
+
if(type == 'boolean') new_value = !$(this).data('field-value');
|
114
|
+
else if(type == 'select') new_value = $(this).val();
|
115
115
|
else new_value = $(this).text();
|
116
116
|
var data = {};
|
117
117
|
data[$(this).data('field')] = new_value;
|
@@ -119,94 +119,91 @@ function dfUpdateField() {
|
|
119
119
|
context: _this,
|
120
120
|
data: { data: data },
|
121
121
|
method: 'POST',
|
122
|
-
url: $(this).data(
|
123
|
-
complete: function(
|
124
|
-
$(this).data(
|
122
|
+
url: $(this).data('save-url'),
|
123
|
+
complete: function(req, status) {
|
124
|
+
$(this).data('loading', '0');
|
125
125
|
},
|
126
|
-
success: function(
|
127
|
-
if(
|
128
|
-
if(
|
126
|
+
success: function(data, status, req) {
|
127
|
+
if(data.status == 'error') {
|
128
|
+
if($(this).data('show-errors')) {
|
129
129
|
var result = '';
|
130
130
|
var message = data.message;
|
131
|
-
for(
|
132
|
-
if(
|
133
|
-
if(
|
134
|
-
result += key + ': ' + message[key].join(
|
131
|
+
for(var key in message) {
|
132
|
+
if(typeof(message[key]) === 'object') {
|
133
|
+
if(result) result += ' - ';
|
134
|
+
result += key + ': ' + message[key].join('; ');
|
135
135
|
}
|
136
136
|
}
|
137
|
-
if(
|
137
|
+
if(result) alert(result);
|
138
138
|
}
|
139
139
|
}
|
140
140
|
else {
|
141
|
-
$(this).data(
|
142
|
-
if(
|
141
|
+
$(this).data('field-value', new_value);
|
142
|
+
if($(this).data('content')) {
|
143
143
|
var old_text = $(this).text();
|
144
|
-
var old_class = $(this).attr(
|
144
|
+
var old_class = $(this).attr('class');
|
145
145
|
var content = $($(this).data('content'));
|
146
|
-
$(this).text(
|
147
|
-
$(this).attr(
|
148
|
-
content.text(
|
149
|
-
content.attr(
|
150
|
-
$(this).data(
|
146
|
+
$(this).text(content.text());
|
147
|
+
$(this).attr('class', content.attr('class'));
|
148
|
+
content.text(old_text);
|
149
|
+
content.attr('class', old_class);
|
150
|
+
$(this).data('content', content);
|
151
151
|
}
|
152
152
|
}
|
153
|
-
}
|
154
|
-
// error: function( req, status, error ) {
|
155
|
-
// // if( $(this).data( 'show-errors' ) && req.responseJSON.message ) { }
|
156
|
-
// },
|
153
|
+
}
|
157
154
|
});
|
158
155
|
}
|
159
156
|
}
|
160
157
|
|
161
158
|
// Init
|
162
|
-
$(document).ready(
|
159
|
+
$(document).ready(function() {
|
163
160
|
// Setup dynamic fields
|
164
|
-
$('.active_admin .input [data-if], .active_admin .input [data-function], .active_admin .input [data-eq], .active_admin .input [data-not]').each(
|
165
|
-
dfSetupField(
|
161
|
+
$('.active_admin .input [data-if], .active_admin .input [data-function], .active_admin .input [data-eq], .active_admin .input [data-not]').each(function() {
|
162
|
+
dfSetupField($(this));
|
166
163
|
});
|
167
164
|
// Setup dynamic fields for has many associations
|
168
|
-
$('.active_admin .has_many_container').on(
|
169
|
-
$('.active_admin .input [data-if], .active_admin .input [data-function], .active_admin .input [data-eq], .active_admin .input [data-not]').each(
|
170
|
-
dfSetupField(
|
165
|
+
$('.active_admin .has_many_container').on('has_many_add:after', function(e, fieldset, container) {
|
166
|
+
$('.active_admin .input [data-if], .active_admin .input [data-function], .active_admin .input [data-eq], .active_admin .input [data-not]').each(function() {
|
167
|
+
dfSetupField($(this));
|
171
168
|
});
|
172
169
|
});
|
173
170
|
// Set dialog icon link
|
174
|
-
$('.active_admin [data-df-icon]').each(
|
175
|
-
$(this).append(
|
171
|
+
$('.active_admin [data-df-icon]').each(function() {
|
172
|
+
$(this).append(' »'); // ' •'
|
176
173
|
});
|
177
174
|
// Open content in dialog
|
178
|
-
$('.active_admin [data-df-dialog]').on(
|
175
|
+
$('.active_admin [data-df-dialog]').on('click', function(event) {
|
179
176
|
event.preventDefault();
|
180
177
|
$(this).blur();
|
181
|
-
if(
|
182
|
-
$('#df-dialog').data(
|
183
|
-
if(
|
184
|
-
var title = $(this).attr(
|
178
|
+
if($('#df-dialog').data('loading') != '1') {
|
179
|
+
$('#df-dialog').data('loading', '1');
|
180
|
+
if($('#df-dialog').length == 0) $('body').append('<div id="df-dialog"></div>');
|
181
|
+
var title = $(this).attr('title');
|
185
182
|
$.ajax({
|
186
|
-
url: $(this).attr(
|
187
|
-
complete: function(
|
188
|
-
$('#df-dialog').data(
|
183
|
+
url: $(this).attr('href'),
|
184
|
+
complete: function(req, status) {
|
185
|
+
$('#df-dialog').data('loading', '0');
|
189
186
|
},
|
190
|
-
success: function(
|
191
|
-
if(
|
192
|
-
$('#df-dialog').html(
|
187
|
+
success: function(data, status, req) {
|
188
|
+
if(title) $('#df-dialog').attr('title', title);
|
189
|
+
$('#df-dialog').html(data);
|
193
190
|
$('#df-dialog').dialog({ modal: true });
|
194
191
|
},
|
195
192
|
});
|
196
193
|
}
|
197
194
|
});
|
198
195
|
// Inline editing
|
199
|
-
$('[data-field][data-field-type="boolean"][data-save-url]').each(
|
200
|
-
$(this).on(
|
196
|
+
$('[data-field][data-field-type="boolean"][data-save-url]').each(function() {
|
197
|
+
$(this).on('click', $.proxy(dfUpdateField, $(this)));
|
201
198
|
});
|
202
|
-
$('[data-field][data-field-type="string"][data-save-url]'
|
203
|
-
$(this).data(
|
204
|
-
var fnUpdate = $.proxy(
|
205
|
-
$(this).on(
|
206
|
-
if(
|
199
|
+
$('[data-field][data-field-type="string"][data-save-url]').each(function() {
|
200
|
+
$(this).data('field-value', $(this).text());
|
201
|
+
var fnUpdate = $.proxy(dfUpdateField, $(this));
|
202
|
+
$(this).on('blur', function() {
|
203
|
+
if($(this).data('field-value') != $(this).text()) fnUpdate();
|
207
204
|
});
|
208
205
|
});
|
209
|
-
$('[data-field][data-field-type="select"][data-save-url]').each(
|
210
|
-
$(this).on(
|
206
|
+
$('[data-field][data-field-type="select"][data-save-url]').each(function() {
|
207
|
+
$(this).on('change', $.proxy(dfUpdateField, $(this)));
|
211
208
|
});
|
212
209
|
});
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_admin'
|
2
4
|
|
3
5
|
module ActiveAdmin
|
@@ -6,21 +8,39 @@ module ActiveAdmin
|
|
6
8
|
engine_name 'activeadmin_dynamic_fields'
|
7
9
|
end
|
8
10
|
|
9
|
-
def self.edit_boolean(
|
10
|
-
{
|
11
|
+
def self.edit_boolean(field, url, value)
|
12
|
+
{
|
13
|
+
'data-field': field,
|
14
|
+
'data-field-type': 'boolean',
|
15
|
+
'data-field-value': value,
|
16
|
+
'data-content': "<span class=\"status_tag changed\">#{value ? 'no' : 'yes'}</span>",
|
17
|
+
'data-save-url': url,
|
18
|
+
'data-show-errors': '1'
|
19
|
+
}
|
11
20
|
end
|
12
21
|
|
13
|
-
def self.edit_select(
|
14
|
-
{
|
22
|
+
def self.edit_select(field, url)
|
23
|
+
{
|
24
|
+
'data-field': field,
|
25
|
+
'data-field-type': 'select',
|
26
|
+
'data-save-url': url,
|
27
|
+
'data-show-errors': '1'
|
28
|
+
}
|
15
29
|
end
|
16
30
|
|
17
|
-
def self.edit_string(
|
18
|
-
{
|
31
|
+
def self.edit_string(field, url)
|
32
|
+
{
|
33
|
+
contenteditable: true,
|
34
|
+
'data-field': field,
|
35
|
+
'data-field-type': 'string',
|
36
|
+
'data-save-url': url,
|
37
|
+
'data-show-errors': '1'
|
38
|
+
}
|
19
39
|
end
|
20
40
|
|
21
|
-
def self.update(
|
41
|
+
def self.update(resource, params, permit_params = nil)
|
22
42
|
if params[:data]
|
23
|
-
if resource.update(
|
43
|
+
if resource.update(permit_params ? params[:data].permit(permit_params) : params[:data].permit!)
|
24
44
|
{ json: { status: 'ok' } }
|
25
45
|
else
|
26
46
|
{ json: { status: 'error', message: resource.errors } }
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_dynamic_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
description: An Active Admin plugin to add dynamic behaviors to fields
|
@@ -31,6 +31,7 @@ extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
33
|
- ".gitignore"
|
34
|
+
- ".rubocop.yml"
|
34
35
|
- Gemfile
|
35
36
|
- LICENSE.txt
|
36
37
|
- README.md
|
@@ -60,8 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
61
|
- !ruby/object:Gem::Version
|
61
62
|
version: '0'
|
62
63
|
requirements: []
|
63
|
-
|
64
|
-
rubygems_version: 2.6.14
|
64
|
+
rubygems_version: 3.0.2
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: Dynamic fields for ActiveAdmin
|