dynamic_fieldsets 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Gemfile +21 -0
- data/Gemfile.lock +157 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +69 -0
- data/VERSION +1 -0
- data/app/controllers/dynamic_fieldsets/fields_controller.rb +75 -0
- data/app/controllers/dynamic_fieldsets/fieldset_associators_controller.rb +24 -0
- data/app/controllers/dynamic_fieldsets/fieldsets_controller.rb +89 -0
- data/app/helpers/dynamic_fieldsets/fields_helper.rb +19 -0
- data/app/helpers/dynamic_fieldsets_helper.rb +207 -0
- data/app/models/dynamic_fieldsets/field.rb +85 -0
- data/app/models/dynamic_fieldsets/field_default.rb +14 -0
- data/app/models/dynamic_fieldsets/field_html_attribute.rb +15 -0
- data/app/models/dynamic_fieldsets/field_option.rb +18 -0
- data/app/models/dynamic_fieldsets/field_record.rb +11 -0
- data/app/models/dynamic_fieldsets/fieldset.rb +57 -0
- data/app/models/dynamic_fieldsets/fieldset_associator.rb +76 -0
- data/app/views/dynamic_fieldsets/fields/_field_default_fields.html.erb +7 -0
- data/app/views/dynamic_fieldsets/fields/_field_html_attribute_fields.html.erb +8 -0
- data/app/views/dynamic_fieldsets/fields/_field_option_fields.html.erb +6 -0
- data/app/views/dynamic_fieldsets/fields/_form.html.erb +81 -0
- data/app/views/dynamic_fieldsets/fields/edit.html.erb +6 -0
- data/app/views/dynamic_fieldsets/fields/index.html.erb +29 -0
- data/app/views/dynamic_fieldsets/fields/new.html.erb +5 -0
- data/app/views/dynamic_fieldsets/fields/show.html.erb +70 -0
- data/app/views/dynamic_fieldsets/fieldset_associators/index.html.erb +18 -0
- data/app/views/dynamic_fieldsets/fieldset_associators/show.html.erb +26 -0
- data/app/views/dynamic_fieldsets/fieldsets/_form.html.erb +37 -0
- data/app/views/dynamic_fieldsets/fieldsets/children.html.erb +45 -0
- data/app/views/dynamic_fieldsets/fieldsets/edit.html.erb +6 -0
- data/app/views/dynamic_fieldsets/fieldsets/index.html.erb +31 -0
- data/app/views/dynamic_fieldsets/fieldsets/new.html.erb +5 -0
- data/app/views/dynamic_fieldsets/fieldsets/show.html.erb +31 -0
- data/config/routes.rb +9 -0
- data/dynamic_fieldsets.gemspec +195 -0
- data/lib/dynamic_fieldsets/config.rb +0 -0
- data/lib/dynamic_fieldsets/dynamic_fieldsets_in_model.rb +164 -0
- data/lib/dynamic_fieldsets/engine.rb +4 -0
- data/lib/dynamic_fieldsets/railtie.rb +13 -0
- data/lib/dynamic_fieldsets.rb +2 -0
- data/lib/generators/dynamic_fieldsets/install_generator.rb +44 -0
- data/lib/generators/dynamic_fieldsets/templates/config.rb +0 -0
- data/lib/generators/dynamic_fieldsets/templates/migrations/install_migration.rb +74 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/information_forms_controller.rb +85 -0
- data/spec/dummy/app/helpers/application_helper.rb +5 -0
- data/spec/dummy/app/helpers/information_forms_helper.rb +2 -0
- data/spec/dummy/app/models/information_form.rb +3 -0
- data/spec/dummy/app/views/information_forms/_form.html.erb +22 -0
- data/spec/dummy/app/views/information_forms/edit.html.erb +6 -0
- data/spec/dummy/app/views/information_forms/index.html.erb +23 -0
- data/spec/dummy/app/views/information_forms/new.html.erb +5 -0
- data/spec/dummy/app/views/information_forms/show.html.erb +11 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20110726215814_create_dynamic_fieldsets_tables.rb +74 -0
- data/spec/dummy/db/migrate/20110727210451_create_information_forms.rb +13 -0
- data/spec/dummy/db/schema.rb +83 -0
- data/spec/dummy/features/field.feature +54 -0
- data/spec/dummy/features/fieldset.feature +68 -0
- data/spec/dummy/features/fieldset_associator.feature +20 -0
- data/spec/dummy/features/step_definitions/debugging_steps.rb +8 -0
- data/spec/dummy/features/step_definitions/field_steps.rb +63 -0
- data/spec/dummy/features/step_definitions/fieldset_associator_steps.rb +11 -0
- data/spec/dummy/features/step_definitions/fieldset_steps.rb +57 -0
- data/spec/dummy/features/step_definitions/web_steps.rb +214 -0
- data/spec/dummy/features/support/env.rb +15 -0
- data/spec/dummy/features/support/paths.rb +46 -0
- data/spec/dummy/features/support/selectors.rb +39 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/jquery.min.js +166 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/public/stylesheets/scaffold.css +56 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dynamic_fieldsets_helper_spec.rb +254 -0
- data/spec/dynamic_fieldsets_in_model_spec.rb +175 -0
- data/spec/dynamic_fieldsets_spec.rb +7 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/models/field_default_spec.rb +26 -0
- data/spec/models/field_html_attribute_spec.rb +30 -0
- data/spec/models/field_option_spec.rb +52 -0
- data/spec/models/field_record_spec.rb +44 -0
- data/spec/models/field_spec.rb +169 -0
- data/spec/models/fieldset_associator_spec.rb +128 -0
- data/spec/models/fieldset_spec.rb +169 -0
- data/spec/reports/SPEC-ActsAsMultipartForm.xml +9 -0
- data/spec/reports/SPEC-MultipartForm-InProgressForm-validations.xml +47 -0
- data/spec/reports/SPEC-MultipartForm-InProgressForm.xml +7 -0
- data/spec/reports/SPEC-Navigation.xml +9 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/support/field_default_helper.rb +12 -0
- data/spec/support/field_helper.rb +16 -0
- data/spec/support/field_html_attribute_helper.rb +14 -0
- data/spec/support/field_option_helper.rb +13 -0
- data/spec/support/field_record_helper.rb +12 -0
- data/spec/support/fieldset_associator_helper.rb +12 -0
- data/spec/support/fieldset_helper.rb +28 -0
- metadata +328 -0
data/CHANGELOG
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "rails", "3.0.7"
|
4
|
+
gem "capybara", ">= 0.4.0"
|
5
|
+
gem "sqlite3"
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'ruby-debug19'
|
9
|
+
gem "rspec", "~> 2.6.0"
|
10
|
+
gem "rspec-rails", "~>2.6.1"
|
11
|
+
gem "yard", "~> 0.6.0"
|
12
|
+
gem "cucumber", ">= 0"
|
13
|
+
gem "cucumber-rails"
|
14
|
+
gem "database_cleaner"
|
15
|
+
gem "bundler", "~> 1.0.0"
|
16
|
+
gem "jeweler", "~> 1.6.3"
|
17
|
+
gem "rcov", ">= 0"
|
18
|
+
|
19
|
+
# hudson ci
|
20
|
+
gem "ci_reporter"
|
21
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.7)
|
6
|
+
actionpack (= 3.0.7)
|
7
|
+
mail (~> 2.2.15)
|
8
|
+
actionpack (3.0.7)
|
9
|
+
activemodel (= 3.0.7)
|
10
|
+
activesupport (= 3.0.7)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.5.0)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.14)
|
16
|
+
rack-test (~> 0.5.7)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.7)
|
19
|
+
activesupport (= 3.0.7)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.5.0)
|
22
|
+
activerecord (3.0.7)
|
23
|
+
activemodel (= 3.0.7)
|
24
|
+
activesupport (= 3.0.7)
|
25
|
+
arel (~> 2.0.2)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.7)
|
28
|
+
activemodel (= 3.0.7)
|
29
|
+
activesupport (= 3.0.7)
|
30
|
+
activesupport (3.0.7)
|
31
|
+
archive-tar-minitar (0.5.2)
|
32
|
+
arel (2.0.10)
|
33
|
+
builder (2.1.2)
|
34
|
+
capybara (1.0.0)
|
35
|
+
mime-types (>= 1.16)
|
36
|
+
nokogiri (>= 1.3.3)
|
37
|
+
rack (>= 1.0.0)
|
38
|
+
rack-test (>= 0.5.4)
|
39
|
+
selenium-webdriver (~> 0.2.0)
|
40
|
+
xpath (~> 0.1.4)
|
41
|
+
childprocess (0.1.9)
|
42
|
+
ffi (~> 1.0.6)
|
43
|
+
ci_reporter (1.6.5)
|
44
|
+
builder (>= 2.1.2)
|
45
|
+
columnize (0.3.4)
|
46
|
+
cucumber (1.0.1)
|
47
|
+
builder (>= 2.1.2)
|
48
|
+
diff-lcs (>= 1.1.2)
|
49
|
+
gherkin (~> 2.4.5)
|
50
|
+
json (>= 1.4.6)
|
51
|
+
term-ansicolor (>= 1.0.5)
|
52
|
+
cucumber-rails (1.0.2)
|
53
|
+
capybara (>= 1.0.0)
|
54
|
+
cucumber (~> 1.0.0)
|
55
|
+
nokogiri (>= 1.4.6)
|
56
|
+
database_cleaner (0.6.7)
|
57
|
+
diff-lcs (1.1.2)
|
58
|
+
erubis (2.6.6)
|
59
|
+
abstract (>= 1.0.0)
|
60
|
+
ffi (1.0.9)
|
61
|
+
gherkin (2.4.5)
|
62
|
+
json (>= 1.4.6)
|
63
|
+
git (1.2.5)
|
64
|
+
i18n (0.5.0)
|
65
|
+
jeweler (1.6.4)
|
66
|
+
bundler (~> 1.0)
|
67
|
+
git (>= 1.2.5)
|
68
|
+
rake
|
69
|
+
json (1.5.3)
|
70
|
+
json_pure (1.5.3)
|
71
|
+
linecache19 (0.5.12)
|
72
|
+
ruby_core_source (>= 0.1.4)
|
73
|
+
mail (2.2.19)
|
74
|
+
activesupport (>= 2.3.6)
|
75
|
+
i18n (>= 0.4.0)
|
76
|
+
mime-types (~> 1.16)
|
77
|
+
treetop (~> 1.4.8)
|
78
|
+
mime-types (1.16)
|
79
|
+
nokogiri (1.5.0)
|
80
|
+
polyglot (0.3.1)
|
81
|
+
rack (1.2.3)
|
82
|
+
rack-mount (0.6.14)
|
83
|
+
rack (>= 1.0.0)
|
84
|
+
rack-test (0.5.7)
|
85
|
+
rack (>= 1.0)
|
86
|
+
rails (3.0.7)
|
87
|
+
actionmailer (= 3.0.7)
|
88
|
+
actionpack (= 3.0.7)
|
89
|
+
activerecord (= 3.0.7)
|
90
|
+
activeresource (= 3.0.7)
|
91
|
+
activesupport (= 3.0.7)
|
92
|
+
bundler (~> 1.0)
|
93
|
+
railties (= 3.0.7)
|
94
|
+
railties (3.0.7)
|
95
|
+
actionpack (= 3.0.7)
|
96
|
+
activesupport (= 3.0.7)
|
97
|
+
rake (>= 0.8.7)
|
98
|
+
thor (~> 0.14.4)
|
99
|
+
rake (0.9.2)
|
100
|
+
rcov (0.9.9)
|
101
|
+
rspec (2.6.0)
|
102
|
+
rspec-core (~> 2.6.0)
|
103
|
+
rspec-expectations (~> 2.6.0)
|
104
|
+
rspec-mocks (~> 2.6.0)
|
105
|
+
rspec-core (2.6.4)
|
106
|
+
rspec-expectations (2.6.0)
|
107
|
+
diff-lcs (~> 1.1.2)
|
108
|
+
rspec-mocks (2.6.0)
|
109
|
+
rspec-rails (2.6.1)
|
110
|
+
actionpack (~> 3.0)
|
111
|
+
activesupport (~> 3.0)
|
112
|
+
railties (~> 3.0)
|
113
|
+
rspec (~> 2.6.0)
|
114
|
+
ruby-debug-base19 (0.11.25)
|
115
|
+
columnize (>= 0.3.1)
|
116
|
+
linecache19 (>= 0.5.11)
|
117
|
+
ruby_core_source (>= 0.1.4)
|
118
|
+
ruby-debug19 (0.11.6)
|
119
|
+
columnize (>= 0.3.1)
|
120
|
+
linecache19 (>= 0.5.11)
|
121
|
+
ruby-debug-base19 (>= 0.11.19)
|
122
|
+
ruby_core_source (0.1.5)
|
123
|
+
archive-tar-minitar (>= 0.5.2)
|
124
|
+
rubyzip (0.9.4)
|
125
|
+
selenium-webdriver (0.2.2)
|
126
|
+
childprocess (>= 0.1.9)
|
127
|
+
ffi (>= 1.0.7)
|
128
|
+
json_pure
|
129
|
+
rubyzip
|
130
|
+
sqlite3 (1.3.3)
|
131
|
+
term-ansicolor (1.0.5)
|
132
|
+
thor (0.14.6)
|
133
|
+
treetop (1.4.9)
|
134
|
+
polyglot (>= 0.3.1)
|
135
|
+
tzinfo (0.3.29)
|
136
|
+
xpath (0.1.4)
|
137
|
+
nokogiri (~> 1.3)
|
138
|
+
yard (0.6.8)
|
139
|
+
|
140
|
+
PLATFORMS
|
141
|
+
ruby
|
142
|
+
|
143
|
+
DEPENDENCIES
|
144
|
+
bundler (~> 1.0.0)
|
145
|
+
capybara (>= 0.4.0)
|
146
|
+
ci_reporter
|
147
|
+
cucumber
|
148
|
+
cucumber-rails
|
149
|
+
database_cleaner
|
150
|
+
jeweler (~> 1.6.3)
|
151
|
+
rails (= 3.0.7)
|
152
|
+
rcov
|
153
|
+
rspec (~> 2.6.0)
|
154
|
+
rspec-rails (~> 2.6.1)
|
155
|
+
ruby-debug19
|
156
|
+
sqlite3
|
157
|
+
yard (~> 0.6.0)
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= DynamicFieldsets
|
2
|
+
|
3
|
+
User defined fieldsets for dynamic questions in forms.
|
4
|
+
|
5
|
+
== Contributing to acts_as_multipart_form
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Jeremiah Hemphill. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "dynamic_fieldsets"
|
18
|
+
gem.homepage = "http://github.com/jeremiahishere/dynamic_fieldsets"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Dynamic fieldsets for rails controllers}
|
21
|
+
gem.description = %Q{Dynamic fieldsets for rails controllers}
|
22
|
+
gem.email = "jeremiah@cloudspace.com"
|
23
|
+
gem.authors = ["Jeremiah Hemphill", "Ethan Pemble"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
require 'cucumber/rake/task'
|
40
|
+
Cucumber::Rake::Task.new(:features)
|
41
|
+
|
42
|
+
task :default => :spec
|
43
|
+
|
44
|
+
require 'yard'
|
45
|
+
YARD::Rake::YardocTask.new
|
46
|
+
|
47
|
+
# hudson ci
|
48
|
+
require 'ci/reporter/rake/rspec'
|
49
|
+
namespace :hudson do
|
50
|
+
def report_path
|
51
|
+
"spec/reports/"
|
52
|
+
end
|
53
|
+
|
54
|
+
task :report_setup do
|
55
|
+
rm_rf report_path
|
56
|
+
mkdir_p report_path
|
57
|
+
end
|
58
|
+
|
59
|
+
# hudson cucumber rake task
|
60
|
+
Cucumber::Rake::Task.new(:cucumber, "Run cucumber with hudson output") do |t|
|
61
|
+
t.cucumber_opts = %{spec/dummy/features --format junit --out #{report_path}}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
#general cucumber rake task
|
66
|
+
require 'cucumber/rake/task'
|
67
|
+
Cucumber::Rake::Task.new(:cucumber, 'run features that should pass') do |t|
|
68
|
+
t.cucumber_opts = "spec/dummy/features --format progress"
|
69
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module DynamicFieldsets
|
2
|
+
class FieldsController < ApplicationController
|
3
|
+
include FieldsHelper
|
4
|
+
unloadable
|
5
|
+
|
6
|
+
# GET /dynamic_fieldsets/fields
|
7
|
+
def index
|
8
|
+
@fields = DynamicFieldsets::Field.all
|
9
|
+
|
10
|
+
respond_to do |format|
|
11
|
+
format.html # index.html.erb
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /dynamic_fieldsets/fields/1
|
16
|
+
def show
|
17
|
+
@field = DynamicFieldsets::Field.find(params[:id])
|
18
|
+
|
19
|
+
respond_to do |format|
|
20
|
+
format.html # show.html.erb
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET /dynamic_fieldsets/fields/new
|
25
|
+
def new
|
26
|
+
@field = DynamicFieldsets::Field.new
|
27
|
+
|
28
|
+
respond_to do |format|
|
29
|
+
format.html # new.html.erb
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# GET /dynamic_fieldsets/fields/1/edit
|
34
|
+
def edit
|
35
|
+
@field = DynamicFieldsets::Field.find(params[:id])
|
36
|
+
end
|
37
|
+
|
38
|
+
# POST /dynamic_fieldsets/fields
|
39
|
+
def create
|
40
|
+
@field = DynamicFieldsets::Field.new(params[:dynamic_fieldsets_field])
|
41
|
+
|
42
|
+
respond_to do |format|
|
43
|
+
if @field.save
|
44
|
+
format.html { redirect_to(@field, :notice => 'Successfully created a new field.') }
|
45
|
+
else
|
46
|
+
format.html { render :action => "new" }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# PUT /dynamic_fieldsets/fields/1
|
52
|
+
def update
|
53
|
+
@field = DynamicFieldsets::Field.find(params[:id])
|
54
|
+
|
55
|
+
respond_to do |format|
|
56
|
+
if @field.update_attributes(params[:dynamic_fieldsets_field])
|
57
|
+
format.html { redirect_to(@field, :notice => 'Successfully updated a field.') }
|
58
|
+
else
|
59
|
+
format.html { render :action => "edit" }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# DELETE /dynamic_fieldsets/fields/1
|
65
|
+
# DELETE /dynamic_fieldsets/fields/1.xml
|
66
|
+
def destroy
|
67
|
+
@field = DynamicFieldsets::Field.find(params[:id])
|
68
|
+
@field.destroy
|
69
|
+
|
70
|
+
respond_to do |format|
|
71
|
+
format.html { redirect_to(dynamic_fieldsets_fields_url) }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Controller for the FieldsetAssociator model
|
2
|
+
# Allows users to view but not create or edit fieldset associators
|
3
|
+
module DynamicFieldsets
|
4
|
+
class FieldsetAssociatorsController < ApplicationController
|
5
|
+
unloadable
|
6
|
+
|
7
|
+
# show all fieldset associators
|
8
|
+
def index
|
9
|
+
@fieldset_associators = DynamicFieldsets::FieldsetAssociator.all
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
format.html
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# show one fieldset associator
|
17
|
+
def show
|
18
|
+
@fieldset_associator = DynamicFieldsets::FieldsetAssociator.find_by_id(params[:id])
|
19
|
+
respond_to do |format|
|
20
|
+
format.html
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module DynamicFieldsets
|
2
|
+
# Basic controller for managing fieldsets
|
3
|
+
class FieldsetsController < ApplicationController
|
4
|
+
unloadable
|
5
|
+
|
6
|
+
# Show all record
|
7
|
+
def index
|
8
|
+
@fieldsets = DynamicFieldsets::Fieldset.all
|
9
|
+
|
10
|
+
respond_to do |format|
|
11
|
+
format.html
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Show single record
|
16
|
+
def show
|
17
|
+
@fieldset = DynamicFieldsets::Fieldset.find_by_id(params[:id])
|
18
|
+
|
19
|
+
respond_to do |format|
|
20
|
+
format.html
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Create new record
|
25
|
+
def new
|
26
|
+
@fieldset = DynamicFieldsets::Fieldset.new()
|
27
|
+
|
28
|
+
respond_to do |format|
|
29
|
+
format.html
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Edit existing record
|
34
|
+
def edit
|
35
|
+
@fieldset = DynamicFieldsets::Fieldset.find_by_id(params[:id])
|
36
|
+
|
37
|
+
respond_to do |format|
|
38
|
+
format.html
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Show a record and all children
|
43
|
+
def children
|
44
|
+
@fieldset_family = DynamicFieldsets::Fieldset.find_by_id(params[:id]).children
|
45
|
+
@parent_fieldset = DynamicFieldsets::Fieldset.find_by_id(params[:id])
|
46
|
+
|
47
|
+
respond_to do |format|
|
48
|
+
format.html
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Save new record
|
53
|
+
def create
|
54
|
+
@fieldset = DynamicFieldsets::Fieldset.new(params[:dynamic_fieldsets_fieldset])
|
55
|
+
|
56
|
+
respond_to do |format|
|
57
|
+
if @fieldset.save
|
58
|
+
format.html { redirect_to( dynamic_fieldsets_fieldset_path(@fieldset), :notice => "Successfully created a new fieldset" )}
|
59
|
+
else
|
60
|
+
format.html { render :action => "new" }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Update existing record
|
66
|
+
def update
|
67
|
+
@fieldset = DynamicFieldsets::Fieldset.find_by_id(params[:id])
|
68
|
+
|
69
|
+
respond_to do |format|
|
70
|
+
if @fieldset.update_attributes(params[:dynamic_fieldsets_fieldset])
|
71
|
+
format.html { redirect_to( dynamic_fieldsets_fieldset_path(@fieldset), :notice => "Successfully updated a fieldset" )}
|
72
|
+
else
|
73
|
+
format.html { render :action => "edit" }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Destroy existing record
|
79
|
+
def destroy
|
80
|
+
@fieldset = DynamicFieldsets::Fieldset.find_by_id(params[:id])
|
81
|
+
@fieldset.destroy
|
82
|
+
|
83
|
+
respond_to do |format|
|
84
|
+
format.html { redirect_to( dynamic_fieldsets_fieldsets_path, :notice => "Fieldset deleted successfully!" )}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module DynamicFieldsets
|
2
|
+
module FieldsHelper
|
3
|
+
|
4
|
+
# returns a link with an onclick call to remove_fields using link_to_function
|
5
|
+
def link_to_remove_fields(name, f)
|
6
|
+
f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
|
7
|
+
end
|
8
|
+
|
9
|
+
# returns a link with an onclick call to add_fields
|
10
|
+
# the field information is rendered from a partial and stored as a string until it is needed
|
11
|
+
def link_to_add_fields(name, f, association)
|
12
|
+
new_object = f.object.class.reflect_on_association(association).klass.new
|
13
|
+
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
|
14
|
+
render(association.to_s.singularize + "_fields", :f => builder)
|
15
|
+
end
|
16
|
+
link_to_function(name, "add_fields(this, '#{association}', '#{escape_javascript(fields)}')")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|