activeadmin_dynamic_fields 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c9721fc5faeb42090d36f2f0200317ad41a4903
|
4
|
+
data.tar.gz: c4b4e0049e7b20bf127b2559f641c4255b67cd2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21956e124e0fce3acd285680693af28885ed0c6bb8a5582a32401d27d4640d97e56c7ba66baed5dabe9ed18eec6b1c67e54a88d4c0e3d580bc4169591614345d
|
7
|
+
data.tar.gz: ace8f765a7fa6d9c6717dc0c95365abb7ddf63a51f354fd967706e1ffc7a28b1f9384120c15b7235975de944cbfb35437ef0ace30375bb0f4b9db092329788e8
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -29,7 +29,8 @@ Options are passed to fields using *input_html* parameter as *data* attributes:
|
|
29
29
|
+ **not_blank**: check if a field is not blank
|
30
30
|
- **data-eq**: check if a field has a specific value
|
31
31
|
- **data-not**: check if a field hasn't a specific value
|
32
|
-
- **data-target**: target css selector
|
32
|
+
- **data-target**: target css selector (from parent fieldset, look for the closest match)
|
33
|
+
- **data-gtarget**: target css selector globally
|
33
34
|
- **data-action**: the action to trigger, values:
|
34
35
|
+ **hide**: hides elements
|
35
36
|
+ **slide**: hides elements (using sliding)
|
@@ -100,7 +101,7 @@ function on_change_category( el ) {
|
|
100
101
|
}
|
101
102
|
```
|
102
103
|
|
103
|
-
### Inline editing
|
104
|
+
### Inline editing examples
|
104
105
|
|
105
106
|
- Prepare a custom member action to save data, an *update* helper function is available (third parameter is optional, allow to filter using strong parameters):
|
106
107
|
|
@@ -5,10 +5,10 @@ function dfEvalCondition( el, args ) {
|
|
5
5
|
else console.log( 'Warning - activeadmin_dynamic_fields: ' + args.fn + '() not available [1]' );
|
6
6
|
}
|
7
7
|
else if( args.if == 'checked' ) {
|
8
|
-
return
|
8
|
+
return el.is(':checked');
|
9
9
|
}
|
10
10
|
else if( args.if == 'not_checked' ) {
|
11
|
-
return el.is(':checked');
|
11
|
+
return !el.is(':checked');
|
12
12
|
}
|
13
13
|
else if( args.if == 'blank' ) {
|
14
14
|
return el.val().length === 0 || !el.val().trim();
|
@@ -33,13 +33,14 @@ function dfSetupField( el ) {
|
|
33
33
|
args.eq = el.data( 'eq' );
|
34
34
|
args.not = el.data( 'not' );
|
35
35
|
args.fn = el.data( 'function' );
|
36
|
-
if( el.data( 'target' ) ) target = el.closest( 'fieldset' ).find( el.data( 'target' ) )
|
36
|
+
if( el.data( 'target' ) ) target = el.closest( 'fieldset' ).find( el.data( 'target' ) ); // closest find for has many associations
|
37
|
+
else if( el.data( 'gtarget' ) ) target = $( el.data( 'gtarget' ) );
|
37
38
|
if( action == 'hide' ) {
|
38
|
-
if( dfEvalCondition( el, args ) ) target.
|
39
|
-
else target.
|
39
|
+
if( dfEvalCondition( el, args ) ) target.hide();
|
40
|
+
else target.show();
|
40
41
|
el.on( 'change', function( event ) {
|
41
|
-
if( dfEvalCondition( $(this), args ) ) target.
|
42
|
-
else target.
|
42
|
+
if( dfEvalCondition( $(this), args ) ) target.hide();
|
43
|
+
else target.show();
|
43
44
|
});
|
44
45
|
}
|
45
46
|
else if( action == 'slide' ) {
|
@@ -12,9 +12,6 @@ module ActiveAdmin
|
|
12
12
|
|
13
13
|
def self.edit_select( field, url )
|
14
14
|
{ 'data-field': field, 'data-field-type': 'select', 'data-save-url': url, 'data-show-errors': '1' }
|
15
|
-
# 'data-field': 'author_id', 'data-field-type': 'select', 'data-save-url': save_admin_article_path( row.id ), 'data-show-errors': '1' do
|
16
|
-
# ( [''] + Author.pluck( :name, :id ) ).map{ |opt| option opt[0], value: opt[1], selected: row.author_id == opt[1] }.join
|
17
|
-
# end
|
18
15
|
end
|
19
16
|
|
20
17
|
def self.edit_string( field, url )
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.1
|
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: 2018-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
63
|
rubyforge_project:
|
64
|
-
rubygems_version: 2.6.
|
64
|
+
rubygems_version: 2.6.14
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: Dynamic fields for ActiveAdmin
|