simple_form_auto_select2 0.0.3 → 0.0.4

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: 7e74f5b45181a7abbef50e1ce4d5d73a1dda819c
4
- data.tar.gz: 4939b094657dba6b9c485a4bef533268dd455c94
3
+ metadata.gz: d93bb9d042dd9d61f7ff5218db1631a365bd5e66
4
+ data.tar.gz: 2e416bd1ffe1e3b8581932ca99fb2d061c4c6087
5
5
  SHA512:
6
- metadata.gz: 63623c72da9b75d9406c9c1930f4c316ce673cf7500c51bb24e363b165aba78fb2da2187d28f798c4f4888a5b6dbe391ede33a1538043d9ba9bfa187bef9f80b
7
- data.tar.gz: 6995429835844225f84e52b5d9d2c9285cf62dba1d4acaf8cf848480877e73b2e719bc596d5d29a2debb7ef0f91837413b938d28bf0184ac2e64eea7d8d7ce7c
6
+ metadata.gz: a900eff91035528caffe466c031e6cb18c9962074b4b9aa41a7f505975c0965ed0ceed48448c898341714ee26844f73362417c0f7bf4353cca1218b11418282a
7
+ data.tar.gz: a0206d66c8564204a9b2c6b1a9ee9f6ad8ca1bebb14b85e4d680da474c42c86ffabea773cab28fc06a95c19c648c1338858c0b974605e40865ea9687434da229
data/README.md CHANGED
@@ -1 +1,27 @@
1
1
  # simple_form_auto_select2
2
+
3
+ Provide select2 input class for simple_form ([simple_form](https://github.com/plataformatec/simple_form)).
4
+
5
+ Based on [auto_select2](https://github.com/Loriowar/auto_select2) gem.
6
+
7
+ [![Gem Version](https://badge.fury.io/rb/simple_form_auto_select2.png)](http://badge.fury.io/rb/simple_form_auto_select2)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'simple_form_auto_select2'
14
+
15
+ ## Usage
16
+
17
+ ### Static select2
18
+
19
+ f.association :project, as: :select2
20
+
21
+ ### Ajax select2
22
+
23
+ f.input :user_id, as: :ajax_select2, placeholder: t(:select_user_from_list),
24
+ default_class_name: :user, default_text_column: [:id, :firstname, :lastname]
25
+
26
+ More info see in documentation of [auto_select2](https://github.com/Loriowar/auto_select2) gem
27
+ and in [auto_select2_tag_example](https://github.com/Loriowar/auto_select2_tag_example) project
@@ -20,6 +20,7 @@ class SimpleForm::Inputs::AjaxSelect2Input < SimpleForm::Inputs::StringInput
20
20
  css_classes << 'multiple'
21
21
  end
22
22
  input_options[:class] = css_classes.compact
23
+ input_options[:value] = value
23
24
  input_options
24
25
  end
25
26
 
@@ -27,6 +28,12 @@ class SimpleForm::Inputs::AjaxSelect2Input < SimpleForm::Inputs::StringInput
27
28
  multiple_by_options? || multiple_by_association?
28
29
  end
29
30
 
31
+ def value
32
+ val = object.public_send(attribute_name)
33
+ val = val.join(',') if val.is_a?(Array)
34
+ val
35
+ end
36
+
30
37
  def multiple_by_association?
31
38
  reflection && [ :has_many, :has_and_belongs_to_many ].include?(reflection.macro)
32
39
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleFormAutoSelect2
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_auto_select2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Lisichkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-21 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties