vue-rails-form-builder 0.6.0 → 0.8.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
- SHA1:
3
- metadata.gz: 211bbcaf159e3c95ae46f5d35d0fba7832163dec
4
- data.tar.gz: 28a332752a4d67590f813b093afd22d56e5a54fa
2
+ SHA256:
3
+ metadata.gz: 1f8285a58cf2280fdccc0f3edff4cf3453be2bd356fd6d865062fe71cb43d14a
4
+ data.tar.gz: da5ad97cf8550ab1a96d035b950035ad66a003d59d8fe5979326e80a2c8db0b8
5
5
  SHA512:
6
- metadata.gz: a07b28dcf78327fc6135f32ce14aacf1a8b1765272d45a4afc23c13317f39dbd187b13002e3de1156abefd575b1780223fb1a89088134f53155372dc41cc4a69
7
- data.tar.gz: 298767defa387e395159788a5e94b00e4879b647f7e52aff9a598c96594cbc8d14060e9ca7e4fb9e10fef109aff70376ba230abff9027eaaf03393b037f65ecd
6
+ metadata.gz: 4955d14e7d6f56fa9482174d23d880528fa6abc6f84229246fe377d37dfe9b8b2ee82e7c0c07b6f8dc77490cc7c350fe033ccfe29f1d08a8608e0a7d6d0c20f3
7
+ data.tar.gz: 0be9aefea352e1c498a9ea7f9b5814c6f0cbcaa2482297e6949b123d4ff1e275d509aa063db77736997c91decbfc6113e9f703d8fea6695b179205f92a5bf2f8
@@ -1,5 +1,21 @@
1
1
  # CHANGELOG - vue-rails-form-builder
2
2
 
3
+ ## 0.8.2 (2018-02-15)
4
+
5
+ * Do override the `file_filed` helper to resolve vue.js options.
6
+
7
+ ## 0.8.1 (2018-02-15)
8
+
9
+ * Don't override the `file_filed` helper. Fix #3.
10
+
11
+ ## 0.8.0 (2017-11-11)
12
+
13
+ * Add `vue_prefix` method to the form builder.
14
+
15
+ ## 0.7.0 (2017-11-11)
16
+
17
+ * Support nested attributes.
18
+
3
19
  ## 0.6.0 (2017-05-14)
4
20
 
5
21
  * Add `vue_scope` option to `vue_form_for` and `vue_form_with` methods.
data/README.md CHANGED
@@ -223,6 +223,48 @@ Example:
223
223
  <% end %>
224
224
  ```
225
225
 
226
+ The `vue_prefix` method of the Form Builder
227
+ -------------------------------------------
228
+
229
+ When you build HTML forms using `vue_form_for`, the form builder has the
230
+ `vue_prefix` method that returns the *prefix string* to the Vue.js property names.
231
+
232
+ See the following code:
233
+
234
+ ```erb
235
+ <%= vue_form_for User.new do |f| %>
236
+ <%= f.text_field :name %>
237
+ <%= f.submit "Create", disabled: "user.name === ''" %>
238
+ <% end %>
239
+ ```
240
+
241
+ The `vue_prefix` method of the form builder (`f`) returns the string `"user"`
242
+ so that you can rewrite the third line of the example above like this:
243
+
244
+ ```erb
245
+ <%= f.submit "Create", disabled: "#{f.vue_prefix}.name === ''" %>
246
+ ```
247
+
248
+ This method is convenient especially when the form has nested attributes:
249
+
250
+ ```erb
251
+ <%= vue_form_for @user do |f| %>
252
+ <%= f.text_field :name %>
253
+ <%= f.fields_for :emails do |g| %>
254
+ <%= g.text_field :address,
255
+ disabled: "user.emails_attributes[#{g.index}]._destroy" %>
256
+ <%= g.check_box :_destroy if g.object.persisted? %>
257
+ <% end %>
258
+ <%= f.submit "Create", disabled: "#{f.vue_prefix}.name === ''" %>
259
+ <% end %>
260
+ ```
261
+
262
+ Using the `vue_prefix` method, you can rewrite the fifth line more concisely:
263
+
264
+ ```erb
265
+ disabled: g.vue_prefix + "._destroy" %>
266
+ ```
267
+
226
268
  Data Initialization
227
269
  -------------------
228
270
 
@@ -4,7 +4,7 @@ module VueRailsFormBuilder
4
4
  class FormBuilder < ActionView::Helpers::FormBuilder
5
5
  include VueRailsFormBuilder::VueOptionsResolver
6
6
 
7
- (field_helpers - [:label, :check_box, :radio_button, :fields_for])
7
+ (field_helpers - [:label, :check_box, :radio_button, :fields_for, :file_field])
8
8
  .each do |selector|
9
9
  class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
10
10
  def #{selector}(method, options = {})
@@ -38,6 +38,11 @@ module VueRailsFormBuilder
38
38
  super(method, choices, options, html_options, &block)
39
39
  end
40
40
 
41
+ def file_field(method, options = {})
42
+ resolve_vue_options(options)
43
+ super(method, options)
44
+ end
45
+
41
46
  def submit(value = nil, options = {})
42
47
  resolve_vue_options(options)
43
48
  super(value, options)
@@ -47,5 +52,13 @@ module VueRailsFormBuilder
47
52
  resolve_vue_options(options)
48
53
  super(value, options, &block)
49
54
  end
55
+
56
+ def vue_prefix
57
+ path = @object_name.gsub(/\[/, ".").gsub(/\]/, "").split(".")
58
+ if @options[:vue_scope]
59
+ path[0] = @options[:vue_scope]
60
+ end
61
+ path.join(".").gsub(/\.(\d+)/, '[\1]')
62
+ end
50
63
  end
51
64
  end
@@ -45,6 +45,7 @@ module VueRailsFormBuilder
45
45
  path[0] = @options[:vue_scope]
46
46
  end
47
47
  options[:"v-model"] ||= (path + [ method ]).join(".")
48
+ options[:"v-model"].gsub!(/\.(\d+)/, '[\1]')
48
49
  end
49
50
  end
50
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vue-rails-form-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.3
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-14 00:00:00.000000000 Z
11
+ date: 2020-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '4.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6'
22
+ version: '7'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '4.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6'
32
+ version: '7'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: railties
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '4.2'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '6'
42
+ version: '7'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '4.2'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '6'
52
+ version: '7'
53
53
  description: 'This gem provides four view helpers for Rails app: vue_form_with, vue_form_for,
54
54
  vue_tag and vue_content_tag.'
55
55
  email: t-kuroda@oiax.jp
@@ -85,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
- rubyforge_project:
89
- rubygems_version: 2.6.11
88
+ rubygems_version: 3.0.3
90
89
  signing_key:
91
90
  specification_version: 4
92
91
  summary: A custom Rails form builder for Vue.js