activeadmin_select_many 0.3.0 → 0.3.2

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: 2f658ea409967f4e0cfe78f48dd192d4047b0050
4
- data.tar.gz: 4275e93e2a65befd4e712b3b884fe278bcd4c3c2
3
+ metadata.gz: ec8fcd1a933a81076b4e8a238e561875dc456303
4
+ data.tar.gz: 7589efb9495414ffbde8634973bdc1c0dfc04259
5
5
  SHA512:
6
- metadata.gz: 7d72c06453f4c81bb5fe90884ad92564e8f1f7ad5068db2e5bcc71bbb027e483e2e55945dc1aa8ad66c5da67614c097649bf84480ddfea32151b80cbc7edbdfe
7
- data.tar.gz: 0e9e9dbc6d36d9c0757ca672d43478a081bf4f6806c49f69a83939eecc386ff8133fbf6846ed540d864e0814c8fede3735243978c4ffbed91cb4fefb01cf6d86
6
+ metadata.gz: 5a9a7ea88ee6d42808b1d9a19e18513c60d5b315f1284b54731a51e67b4369d47feb7738420a435bec862193e21257377483ca10fd0323243b81564c994e4515
7
+ data.tar.gz: 85aef3bcef4b92905054afa7f5dd4f96aa7f44fea894c965dd5157e0908fc198b9e0d1399c112e4a2973cc14cec94a7cfc49eaed6e49747598e1b3590bdede4a
data/README.md CHANGED
@@ -38,6 +38,7 @@ Features for *select_one*:
38
38
  - **collection**: local collection
39
39
  - **counter_limit**: if results count is greater than or equal to this limit a '+' is shown
40
40
  - **filter_form**: for *select_one* only, allow to use it as filter
41
+ - **include_blank**: for *select_one* only, default true, allow to include a blank value on top
41
42
  - **member_label**: key to use as text for select options
42
43
  - **placeholder**: placeholder string for search box
43
44
  - **remote_collection**: JSON path
@@ -181,12 +181,15 @@ $(document).ready( function() {
181
181
  $(this).data( 'searching', '' );
182
182
  },
183
183
  success: function( data, status, req ) {
184
- var sel = $(this);
184
+ var first = false, sel = $(this);
185
185
  sel.empty();
186
+ if( sel.data('include-blank') ) sel.append( $('<option>', { value: '', text: '' }) );
186
187
  data.forEach( function( item ) {
187
188
  sel.append( $('<option>', { value: item[value_key], text: item[text_key] }) );
189
+ if( !first ) first = item[value_key];
188
190
  });
189
191
  sel.parent().find( '.status' ).text( '[' + ( ( counter_limit > 0 && data.length >= counter_limit ) ? ( counter_limit + '+' ) : data.length ) + ']' );
192
+ if( first ) sel.val( first );
190
193
  },
191
194
  });
192
195
  }
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
2
  module SelectMany
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.2'
4
4
  end
5
5
  end
@@ -1,9 +1,9 @@
1
1
  module Formtastic
2
2
  module Inputs
3
3
  class SelectOneInput < SelectInput
4
- def input_options
5
- super.merge include_blank: false
6
- end
4
+ # def input_options
5
+ # super.merge include_blank: false
6
+ # end
7
7
 
8
8
  def input_wrapping(&block)
9
9
  template.content_tag(options[:filter_form] ? :div : :li,
@@ -49,7 +49,9 @@ module Formtastic
49
49
  break
50
50
  end
51
51
  end
52
- builder.select(input_name, sel, input_options, input_html_options.merge( 'data-select': 'src' ) )
52
+ opts = input_html_options.merge( 'data-select': 'src' )
53
+ opts['data-include-blank'] = '1' if input_options[:include_blank]
54
+ builder.select(input_name, sel, input_options, opts )
53
55
  end
54
56
  end
55
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_select_many
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
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-10-21 00:00:00.000000000 Z
11
+ date: 2017-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin