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: d599f816a20b2b7068d3b7d72e7ada1002c848bf
4
- data.tar.gz: 296760d26145ceddb5e535296c1fa8a234e9781d
3
+ metadata.gz: 1c9721fc5faeb42090d36f2f0200317ad41a4903
4
+ data.tar.gz: c4b4e0049e7b20bf127b2559f641c4255b67cd2b
5
5
  SHA512:
6
- metadata.gz: 28779caf4f980c64bffc0cc88e006f0d3ec9b6b1666e53f306a57e9e035c386f7c4f30d55994ee38e610bd337b6922a2470662f5c341b3ca2f77acfbf322b021
7
- data.tar.gz: e078d3ab6b1ddc26c1af8c899c4aa2a903803b59e3f2f56a331e071437fb98265efd8386653fe16f140015e2ce8070f2a7d1b65b6313167ec855d73da3b3b722
6
+ metadata.gz: 21956e124e0fce3acd285680693af28885ed0c6bb8a5582a32401d27d4640d97e56c7ba66baed5dabe9ed18eec6b1c67e54a88d4c0e3d580bc4169591614345d
7
+ data.tar.gz: ace8f765a7fa6d9c6717dc0c95365abb7ddf63a51f354fd967706e1ffc7a28b1f9384120c15b7235975de944cbfb35437ef0ace30375bb0f4b9db092329788e8
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  _misc/
2
-
2
+ Gemfile.lock
3
3
  *.orig
4
+
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 example
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 !el.is(':checked');
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.show();
39
- else target.hide();
39
+ if( dfEvalCondition( el, args ) ) target.hide();
40
+ else target.show();
40
41
  el.on( 'change', function( event ) {
41
- if( dfEvalCondition( $(this), args ) ) target.show();
42
- else target.hide();
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 )
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
2
  module DynamicFields
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
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.0
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: 2017-09-24 00:00:00.000000000 Z
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.13
64
+ rubygems_version: 2.6.14
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: Dynamic fields for ActiveAdmin