nested-fields 0.0.0 → 1.0.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 1.0.0
@@ -4,6 +4,7 @@ class NestedGenerator < Rails::Generators::Base
4
4
  def install
5
5
  # Copy the unobtrusive JS file
6
6
  copy_file('nested-fields.js', 'public/javascripts/nested-fields.js')
7
+ copy_file('nested_fields_helper.rb', 'app/helpers/nested_fields_helper.rb')
7
8
  end
8
9
 
9
10
  def self.source_root
@@ -0,0 +1,15 @@
1
+ module NestedFieldsHelper
2
+ def link_to_remove_fields(name, f)
3
+ f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
4
+ end
5
+
6
+ def link_to_new_child(f, association)
7
+ object = f.object.class.reflect_on_association(association.to_sym).klass.new
8
+
9
+ fields = f.fields_for(association, object, :child_index => "new_#{association.singularize}") do |builder|
10
+ render("#{association.singularize}_fields", :f => builder)
11
+ end
12
+
13
+ link_to_function "Add #{association}", h("add_child_field('#{association}', 'new_#{association.singularize}', \"#{escape_javascript(fields)}\")")
14
+ end
15
+ end
data/lib/nested-fields.rb CHANGED
@@ -4,19 +4,7 @@ module NestedFields
4
4
  end
5
5
 
6
6
  module ClassMethods
7
- def link_to_remove_fields(name, f)
8
- f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
9
- end
10
-
11
- def link_to_new_child(f, association)
12
- object = f.object.class.reflect_on_association(association.to_sym).klass.new
13
-
14
- fields = f.fields_for(association, object, :child_index => "new_#{association.singularize}") do |builder|
15
- render("#{association.singularize}_fields", :f => builder)
16
- end
17
-
18
- link_to_function "Add #{association}", h("add_child_field('#{association}', 'new_#{association.singularize}', \"#{escape_javascript(fields)}\")")
19
- end
7
+
20
8
  end
21
9
  end
22
10
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{nested-fields}
8
- s.version = "0.0.0"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Roberto Sanchez Sanchez"]
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  "VERSION",
26
26
  "lib/generators/nested_generator.rb",
27
27
  "lib/generators/templates/nested-fields.js",
28
+ "lib/generators/templates/nested_fields_helper.rb",
28
29
  "lib/nested-fields.rb",
29
30
  "nested-fields.gemspec",
30
31
  "test/helper.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nested-fields
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
+ - 1
7
8
  - 0
8
9
  - 0
9
- - 0
10
- version: 0.0.0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roberto Sanchez Sanchez
@@ -37,6 +37,7 @@ files:
37
37
  - VERSION
38
38
  - lib/generators/nested_generator.rb
39
39
  - lib/generators/templates/nested-fields.js
40
+ - lib/generators/templates/nested_fields_helper.rb
40
41
  - lib/nested-fields.rb
41
42
  - nested-fields.gemspec
42
43
  - test/helper.rb