vue-form-for 0.3.3 → 0.4.0

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: 7e654439d5253e0f40eb065267bcd4eac23e0f32
4
- data.tar.gz: 92893a8ee0b699345526b520fb751957a2ca2e07
3
+ metadata.gz: 0520bfe0687ca8fe0d7fa4ce7ee8520b789b1b26
4
+ data.tar.gz: 7ca3b9e211ae547545beb3577ec0e6a38e509bc8
5
5
  SHA512:
6
- metadata.gz: 0cd57e5f9e6ec644993ac2a66fb423755ad3a355279dfe9fbff936893bd51e84bec3aed4657df84d130f34c32472310120ad0c7ed8df6cf5576b6b6658660690
7
- data.tar.gz: 67e23b3bc0da0519bac7ebfeeec7e69a955a782742e4157e9cd6c5d3dcdcc02bf6c8e7fb4f59c591bd770a0a8f0e68bf74427f732a9360831a9386264f792aad
6
+ metadata.gz: 8a75589afbfd826b6bf64fe8c86e07a48c48a741eec6df58ee067299656f1b27bb2320aeb519cb3769dbfd3dcef3bb14d74afa8d4512497cd05319bf55f5c514
7
+ data.tar.gz: 773e02a95506fc450a75fe04fb11a10324b5c733fa0c852751d2107e9b717885a6bb521edfd6fab5cf6415ee62e009563ab58087ebe4016bd9db6dfdc51b6d09
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG - vue-form-for
2
2
 
3
+ ## 0.4.0 (2017-05-11)
4
+
5
+ * Support SELECT tag.
6
+
3
7
  ## 0.3.3 (2017-05-09)
4
8
 
5
9
  * Generate v-model attr for check boxes and radio buttons.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  vue-form-for
2
2
  ============
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/vue-form-for.svg)](https://badge.fury.io/rb/vue-form-for)
5
+
4
6
  A custom Rails form builder for Vue.js
5
7
 
6
8
  Synopsis
@@ -195,6 +197,21 @@ Example:
195
197
  <% end %>
196
198
  ```
197
199
 
200
+ Data Initialization
201
+ -------------------
202
+
203
+ As the official Vue.js document says:
204
+
205
+ > `v-model` will ignore the initial `value`, `checked` or `selected` attributes
206
+ > found on any form elements.
207
+ > (https://vuejs.org/v2/guide/forms.html)
208
+
209
+ Because of this, all form controls get reset after the Vue component is mounted.
210
+
211
+ However, you can use
212
+ [vue-data-scooper](https://github.com/kuroda/vue-data-scooper) plugin
213
+ in order to keep the original state of the form.
214
+
198
215
  License
199
216
  -------
200
217
 
@@ -9,8 +9,7 @@ module VueFormFor
9
9
  class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
10
10
  def #{selector}(method, options = {})
11
11
  resolve_vue_options(options)
12
- namespace = @object_name.gsub(/\\[/, ".").gsub(/\\]/, "")
13
- options[:"v-model"] ||= "\#{namespace}.\#{method}"
12
+ add_v_model_attribute(method, options)
14
13
  super(method, options)
15
14
  end
16
15
  RUBY_EVAL
@@ -23,18 +22,22 @@ module VueFormFor
23
22
 
24
23
  def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
25
24
  resolve_vue_options(options)
26
- namespace = @object_name.gsub(/\[/, ".").gsub(/\]/, "")
27
- options[:"v-model"] ||= "#{namespace}.#{method}"
25
+ add_v_model_attribute(method, options)
28
26
  super(method, options, checked_value, unchecked_value)
29
27
  end
30
28
 
31
29
  def radio_button(method, tag_value, options = {})
32
30
  resolve_vue_options(options)
33
- namespace = @object_name.gsub(/\[/, ".").gsub(/\]/, "")
34
- options[:"v-model"] ||= "#{namespace}.#{method}"
31
+ add_v_model_attribute(method, options)
35
32
  super(method, tag_value, options)
36
33
  end
37
34
 
35
+ def select(method, choices = nil, options = {}, html_options = {}, &block)
36
+ resolve_vue_options(html_options)
37
+ add_v_model_attribute(method, html_options)
38
+ super(method, choices, options, html_options, &block)
39
+ end
40
+
38
41
  def submit(value = nil, options = {})
39
42
  resolve_vue_options(options)
40
43
  super(value, options)
@@ -38,5 +38,10 @@ module VueFormFor
38
38
  end
39
39
  end
40
40
  end
41
+
42
+ private def add_v_model_attribute(method, options)
43
+ namespace = @object_name.gsub(/\[/, ".").gsub(/\]/, "")
44
+ options[:"v-model"] ||= "#{namespace}.#{method}"
45
+ end
41
46
  end
42
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vue-form-for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsutomu KURODA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-09 00:00:00.000000000 Z
11
+ date: 2017-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview