activeadmin_selectize 0.1.0 → 0.1.2

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: 75e66c42883ea645b160a3e44a0235abce1cd5a1
4
- data.tar.gz: f6173cd2f8b1af0cd003f966d16ca0b960096b76
3
+ metadata.gz: 7e2093aedb2e382b18c8e1af2d8efc96a2a69f37
4
+ data.tar.gz: b378a94c0b8ca17917b489cb5ce764498a934de1
5
5
  SHA512:
6
- metadata.gz: 723670e3b30c28bf83976df492479ee352131c4df1e40603ee7bb28e48597d593a1c4625f6f5efd9308bd0f532000b8f123d2208a07460ac8e45de53c45f523f
7
- data.tar.gz: 4cadfd4291ad792797c8155fecb83a15c6dc088c450a1cfbcfcbb9c60766fc611360bfee3a0053007077e5053475bf9527a60a8531a1ea5e41f0841d7ddde4a6
6
+ metadata.gz: 1f450b2c81f547de8bc6cce1af359e21a9d42d667daed84eca835ae2054e139e389dc451e93d520e2fad79eb81b1e035c19c2f576aee6c994592df973d8a4082
7
+ data.tar.gz: b1e182ad2dc3c851cc39330dff7dca083f3d08c9ff12f761adbff3ec001356fc3425a9b00fe227fc01ed17951196650f30cee60c71f500b506ca8a1378e33790
data/README.md CHANGED
@@ -6,11 +6,13 @@ Features:
6
6
  - nice select inputs
7
7
  - items search
8
8
  - AJAX content loading
9
+ - improve many-to-many / one-to-many selection
9
10
 
10
11
  ## Install
11
12
 
12
- - Add to your Gemfile (also add _jquery-rails_ or include jQuery manually):
13
+ - Add to your Gemfile:
13
14
  `gem 'activeadmin_selectize'`
15
+ - Add _jquery-rails_ gem or include jQuery manually
14
16
  - Execute bundle
15
17
  - Add at the end of your ActiveAdmin styles (_app/assets/stylesheets/active_admin.scss_):
16
18
  `@import 'activeadmin/selectize_input';`
@@ -21,7 +23,7 @@ Features:
21
23
  ```
22
24
  - Use the input with `as: :selectize` in Active Admin model conf
23
25
 
24
- Why 2 separated scripts? In this way you can include a different version of selectize.js if you like.
26
+ Why 2 separated scripts? In this way you can include a different version of Selectize.js if you like.
25
27
 
26
28
  ## Example
27
29
 
@@ -54,7 +56,11 @@ Pass the required options using `input_html`.
54
56
  - **data-opt-remote**: URL used for AJAX search requests (method GET)
55
57
  - **data-opt-text**: field to use as option label
56
58
  - **data-opt-value**: field to use as select value
57
- - **data-opt-...**: option passed directly to Selectize.js - see [options](https://github.com/selectize/selectize.js/blob/master/docs/usage.md#configuration)
59
+ - **data-opt-NAME**: option _NAME_ passed directly to Selectize.js - see [options](https://github.com/selectize/selectize.js/blob/master/docs/usage.md#configuration)
60
+
61
+ Alternative syntax:
62
+
63
+ - **data-options**: overrides Selectize options - example: `'data-options': '{"highlight":true,"plugins":[]}'`
58
64
 
59
65
  ## Contributors
60
66
 
@@ -13,12 +13,19 @@ $(document).ready( function() {
13
13
  searchField: field_text,
14
14
  valueField: field_value
15
15
  };
16
- $.each( this.attributes, function( i, attr ) {
17
- if( attr.name.startsWith( 'data-opt-' ) ) {
18
- var name = attr.name.substr( 9 );
19
- if( name != 'remote' && name != 'text' && name != 'value' ) opts[name] = ( attr.value == 'true' ) ? true : ( ( attr.value == 'false' ) ? false : attr.value );
20
- }
21
- });
16
+
17
+ if (!$(this).data('options') ) {
18
+ $.each( this.attributes, function( i, attr ) {
19
+ if( attr.name.startsWith( 'data-opt-' ) ) {
20
+ var name = attr.name.substr( 9 );
21
+ if( name != 'remote' && name != 'text' && name != 'value' ) opts[name] = ( attr.value == 'true' ) ? true : ( ( attr.value == 'false' ) ? false : attr.value );
22
+ }
23
+ });
24
+ }
25
+ else {
26
+ opts = $.extend({}, opts, $(this).data('options'));
27
+ }
28
+
22
29
  opts['load'] = function( query, callback ) {
23
30
  if( !query.length ) return callback();
24
31
  $.ajax({
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
2
  module Selectize
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_selectize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.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-05-21 00:00:00.000000000 Z
11
+ date: 2017-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin