effective_form_inputs 0.7.2 → 0.7.3

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: 7c0664f49f601917158c118b1968e0e47a522434
4
- data.tar.gz: 9c05e20493cc2871af15a2e238c72cda0387b05d
3
+ metadata.gz: 3a2f34fb4c7efed49d6f2b2aac5242d655f91d08
4
+ data.tar.gz: 312fffd9da431e7fed5fe47f6ae14b7570345e2c
5
5
  SHA512:
6
- metadata.gz: 9d6c9f14fa21edfc6a4d78ae1ca170a8fa8347123a5483fc87b0f242ae219f2ee5749375931813792d4d03118123495d1ed09634e10452b4032623b0c1916855
7
- data.tar.gz: 164527227c782a2ac7fcb71db22b1fccca9915776e4289c34582313f036053192ce52602c6af70b177ffdb5e68d277f1af5b377964c30e16889d3808113af108
6
+ metadata.gz: 9a64355e4aabd335e02726b7424d908ed7e1f04509929e37a96962d1473fc03636feaa202588f88787c9cf9adfed46f0062338191d6c797ef6367c4d0fb8a481
7
+ data.tar.gz: ed317c875b0962897e4a2cfcce3eba331ea8afac0f0d0cc55ee78f4225104901f5ebb32730e341cadd7f3b720648ceafd8c1afce5be3033e6adcfd15cdfc5b66
data/README.md CHANGED
@@ -271,6 +271,11 @@ Passing `:multiple => true` will allow multiple selections to be made.
271
271
 
272
272
  Passing `:multiple => true, :tags => true` will allow multiple selections to be made, and new value options to be created. This will allow you to both select existing tags and create new tags in the same form control.
273
273
 
274
+ Passing `:grouped => true` will enable optgroup support. When in this mode, the collection should be a Hash of Array of Arrays
275
+
276
+ ```ruby
277
+ :collection => {'Active' => [['Post A', 1], ['Post B', 2]], 'Past' => [['Post C', 3], ['Post D', 4]]}
278
+ ```
274
279
 
275
280
  ### Options
276
281
 
@@ -1,10 +1,10 @@
1
1
  module Inputs
2
2
  module EffectiveSelect
3
3
  class Input < Effective::FormInput
4
- delegate :collection_select, :to => :@template
4
+ delegate :collection_select, :grouped_collection_select, :to => :@template
5
5
 
6
6
  def default_options
7
- {:label_method => :to_s, :value_method => :to_s}
7
+ {label_method: :to_s, value_method: :to_s, group_method: :second, group_label_method: :first, option_key_method: :second, option_value_method: :first}
8
8
  end
9
9
 
10
10
  def default_input_js
@@ -16,7 +16,11 @@ module Inputs
16
16
  end
17
17
 
18
18
  def to_html
19
- collection_select(@object_name, @method, collection, options[:value_method], options[:label_method], options, tag_options)
19
+ if options[:grouped]
20
+ grouped_collection_select(@object_name, @method, collection, options[:group_method], options[:group_label_method], options[:option_key_method], options[:option_value_method], options, tag_options)
21
+ else
22
+ collection_select(@object_name, @method, collection, options[:value_method], options[:label_method], options, tag_options)
23
+ end
20
24
  end
21
25
 
22
26
  def collection
@@ -45,6 +49,7 @@ module Inputs
45
49
  super().tap do |js_options|
46
50
  js_options[:allowClear] = (options[:multiple] != true)
47
51
  js_options[:tags] = (options[:tags] == true)
52
+ js_options[:tokenSeparators] = nil if options[:tags] != true
48
53
  end
49
54
  end
50
55
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveFormInputs
2
- VERSION = '0.7.2'.freeze
2
+ VERSION = '0.7.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_form_inputs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-03 00:00:00.000000000 Z
11
+ date: 2015-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails