nested_form_fields 0.7.8 → 0.8

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: 02d61af1c6293f8421ae8e3c0d9239786a0b67aa
4
- data.tar.gz: 362b4669eb7a3826512a3c3832bfe39538aeb1f1
3
+ metadata.gz: 129eaaa576452be6947868888dbb854785529e65
4
+ data.tar.gz: e8580e4da7760a584c6048171112e55982683c9c
5
5
  SHA512:
6
- metadata.gz: f679f1cdaaaeb1c1c931541c3f3739c2647b75e7ec90c3ebc7fb6b439fcda2540861bb0e36fe3ae652b351c22d2466e174c7bacbc3fbbada57ba08f66a40fa62
7
- data.tar.gz: ad09cd926e9304264bb0f8b1dd741b5eb06582d23e545727b6abe7b01abc6a18148f6933d00dc07d5c1395063b8fa918ed7d840894ebe0951ff34becc583e9bc
6
+ metadata.gz: 820f6d5e432d72232ca6ccd05b1a0623d3065ff491d3f3ef25b094ac39c85c661880dd0ef84bfb7a19dbcea4d6f035fc196f57ab4cb5daa635971a82106008c3
7
+ data.tar.gz: 11affd01bfcb4ef721af92817ad0132fa027d0d55afae542da5a226c36852915d481c455fd897137e75ec27722a8c00939738b11564ad49c4d91efd348e5b9ac
data/README.md CHANGED
@@ -80,7 +80,7 @@ f.add_nested_fields_link :videos, 'Add another funtastic video', class: 'btn btn
80
80
  You can supply a block to the `remove_nested_fields_link` and the `add_nested_fields_link` helpers, as you can with `link_to`:
81
81
 
82
82
  ```haml
83
- = ff.remove_nested_fields_link
83
+ = ff.remove_nested_fields_link do
84
84
  Remove me %span.icon-trash
85
85
  ```
86
86
 
@@ -141,8 +141,8 @@ def user_params
141
141
  params.require(:user)
142
142
  .permit(:name,:email,videos_attributes:[:video_title,:_destroy,:id])
143
143
  # ^^^ ^^^ ^^^
144
- # nested model attrs
145
- # they will let you delete the nested model
144
+ # nested model attrs
145
+ # they will let you delete the nested model
146
146
  end
147
147
  ```
148
148
 
@@ -190,11 +190,11 @@ $(document).on "fields_added.nested_form_fields", (event, param) ->
190
190
 
191
191
  ## Index replacement string
192
192
 
193
- Sometimes your code needs to know what index it has when it is instantiated onto the page.
193
+ Sometimes your code needs to know what index it has when it is instantiated onto the page.
194
194
  HTML data elements may need point to other form elements for instance. This is needed for integration
195
- with rails3-jquery-autocomplete.
195
+ with rails3-jquery-autocomplete.
196
196
 
197
- To enable string substitution with the current index use the magic string '__nested_field_for_replace_with_index__'
197
+ To enable string substitution with the current index use the magic string '\__nested_field_for_replace_with_index\__'.
198
198
 
199
199
  ## Contributing
200
200
 
@@ -73,6 +73,7 @@ module ActionView::Helpers
73
73
  wrapper_options = options[:wrapper_options].clone || {}
74
74
  if child._destroy == true
75
75
  wrapper_options[:style] = wrapper_options[:style] ? wrapper_options[:style] + ';' + 'display:none' : 'display:none'
76
+ output << destroy_hidden_field(association_name, index)
76
77
  end
77
78
  output << nested_fields_wrapper(association_name, options[:wrapper_tag], options[:legend], wrapper_options) do
78
79
  new_block = fields_for_nested_model("#{name}[#{options[:child_index] || nested_child_index(name)}]", child, options, block)
@@ -132,6 +133,11 @@ module ActionView::Helpers
132
133
  end
133
134
  end
134
135
 
136
+ def destroy_hidden_field(association_name, index)
137
+ @template.hidden_field "#{object_name}[#{association_name}_attributes][#{index}]",
138
+ :_destroy, value: 1
139
+ end
140
+
135
141
  def add_default_classes_to_wrapper_options(association_name, wrapper_options)
136
142
  default_classes = ["nested_fields", "nested_#{association_path(association_name)}"]
137
143
  wrapper_options[:class] = wrapper_options[:class].is_a?(String) ? wrapper_options[:class].split(" ") : wrapper_options[:class].to_a
@@ -1,3 +1,3 @@
1
1
  module NestedFormFields
2
- VERSION = "0.7.8"
2
+ VERSION = "0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nested_form_fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: '0.8'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Ritsche
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-07 00:00:00.000000000 Z
11
+ date: 2016-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails