vue-rails-form-builder 0.6.0 → 0.8.3
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 +5 -5
 - data/CHANGELOG.md +16 -0
 - data/README.md +42 -0
 - data/lib/vue-rails-form-builder/form_builder.rb +14 -1
 - data/lib/vue-rails-form-builder/vue_options_resolver.rb +1 -0
 - metadata +7 -8
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 1f8285a58cf2280fdccc0f3edff4cf3453be2bd356fd6d865062fe71cb43d14a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: da5ad97cf8550ab1a96d035b950035ad66a003d59d8fe5979326e80a2c8db0b8
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4955d14e7d6f56fa9482174d23d880528fa6abc6f84229246fe377d37dfe9b8b2ee82e7c0c07b6f8dc77490cc7c350fe033ccfe29f1d08a8608e0a7d6d0c20f3
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 0be9aefea352e1c498a9ea7f9b5814c6f0cbcaa2482297e6949b123d4ff1e275d509aa063db77736997c91decbfc6113e9f703d8fea6695b179205f92a5bf2f8
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -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
         
     | 
    
        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. 
     | 
| 
      
 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:  
     | 
| 
      
 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: ' 
     | 
| 
      
 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: ' 
     | 
| 
      
 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: ' 
     | 
| 
      
 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: ' 
     | 
| 
      
 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 
     | 
    
         
            -
             
     | 
| 
       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
         
     |