dynamic_fieldsets 0.0.2
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/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
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
|
2
|
+
|
|
3
|
+
<p>
|
|
4
|
+
<b>Fieldset:</b>
|
|
5
|
+
<%= @field.fieldset_id %>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p>
|
|
9
|
+
<b>Name:</b>
|
|
10
|
+
<%= @field.name %>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p>
|
|
14
|
+
<b>Label:</b>
|
|
15
|
+
<%= @field.label %>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<p>
|
|
19
|
+
<b>Type:</b>
|
|
20
|
+
<%= @field.field_type %>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<% if @field.field_options.length > 0 %>
|
|
24
|
+
<p>
|
|
25
|
+
<b>Options:</b><br />
|
|
26
|
+
<% @field.field_options.each do |fo| %>
|
|
27
|
+
<%= fo.name %>
|
|
28
|
+
<br />
|
|
29
|
+
<% end %>
|
|
30
|
+
</p>
|
|
31
|
+
<% end %>
|
|
32
|
+
|
|
33
|
+
<p>
|
|
34
|
+
<b>Required:</b>
|
|
35
|
+
<%= @field.required %>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
<p>
|
|
39
|
+
<b>Enabled:</b>
|
|
40
|
+
<%= @field.enabled %>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
<p>
|
|
44
|
+
<b>Order Number:</b>
|
|
45
|
+
<%= @field.order_num %>
|
|
46
|
+
</p>
|
|
47
|
+
|
|
48
|
+
<% if @field.field_defaults.length > 0 %>
|
|
49
|
+
<p>
|
|
50
|
+
<b>Default values:</b><br />
|
|
51
|
+
<% @field.field_defaults.each do |fd| %>
|
|
52
|
+
<%= fd.value %>
|
|
53
|
+
<br />
|
|
54
|
+
<% end %>
|
|
55
|
+
</p>
|
|
56
|
+
<% end %>
|
|
57
|
+
|
|
58
|
+
<% if @field.field_html_attributes.length > 0 %>
|
|
59
|
+
<p>
|
|
60
|
+
<b>Html Attributes:</b><br />
|
|
61
|
+
<% @field.field_html_attributes.each do |fha| %>
|
|
62
|
+
<%= fha.attribute_name %>: <%= fha.value %>
|
|
63
|
+
<br />
|
|
64
|
+
<% end %>
|
|
65
|
+
</p>
|
|
66
|
+
<% end %>
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
<%= link_to 'Edit', edit_dynamic_fieldsets_field_path(@field) %> |
|
|
70
|
+
<%= link_to 'Back', dynamic_fieldsets_fields_path %>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<div class='content'>
|
|
2
|
+
<table>
|
|
3
|
+
<tr>
|
|
4
|
+
<td>Fieldset Model Id</td>
|
|
5
|
+
<td>Fieldset Model Type</td>
|
|
6
|
+
<td>Fieldset Model Name</td>
|
|
7
|
+
<td>Fieldset Name</td>
|
|
8
|
+
</tr>
|
|
9
|
+
<% @fieldset_associators.each do |fieldset_associator| %>
|
|
10
|
+
<tr>
|
|
11
|
+
<td><%= fieldset_associator.fieldset_model_id %></td>
|
|
12
|
+
<td><%= fieldset_associator.fieldset_model_type %></td>
|
|
13
|
+
<td><%= fieldset_associator.fieldset_model_name %></td>
|
|
14
|
+
<td><%= fieldset_associator.fieldset.name %></td>
|
|
15
|
+
</tr>
|
|
16
|
+
<% end %>
|
|
17
|
+
</table>
|
|
18
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<h1 class='pagetitle'>
|
|
2
|
+
Viewing fieldset associator
|
|
3
|
+
</h1>
|
|
4
|
+
|
|
5
|
+
<div class='content'
|
|
6
|
+
<div id='fieldset_associator'>
|
|
7
|
+
<p>
|
|
8
|
+
<b>Fieldset Model Id:</b>
|
|
9
|
+
<%= @fieldset_associator.fieldset_model_id %>
|
|
10
|
+
</p>
|
|
11
|
+
<p>
|
|
12
|
+
<b>Fieldset Model Type</b>
|
|
13
|
+
<%= @fieldset_associator.fieldset_model_type %>
|
|
14
|
+
</p>
|
|
15
|
+
<p>
|
|
16
|
+
<b>Fieldset Model Name</b>
|
|
17
|
+
<%= @fieldset_associator.fieldset_model_name %>
|
|
18
|
+
</p>
|
|
19
|
+
<p>
|
|
20
|
+
<b>Fieldset</b>
|
|
21
|
+
<%= @fieldset_associator.fieldset.name %>
|
|
22
|
+
</p>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<%= link_to "Back", dynamic_fieldsets_fieldset_associators_path %>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<%= form_for(@fieldset) do |f| %>
|
|
2
|
+
<% if @fieldset.errors.any? %>
|
|
3
|
+
<div id="error_explanation">
|
|
4
|
+
<h2><%= pluralize(@fieldset.errors.count, "error") %> prohibited this fieldset from being saved:</h2>
|
|
5
|
+
|
|
6
|
+
<ul>
|
|
7
|
+
<% @fieldset.errors.full_messages.each do |msg| %>
|
|
8
|
+
<li><%= msg %></li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<div class="field">
|
|
15
|
+
<%= f.label :nkey %><br />
|
|
16
|
+
<%= f.text_field :nkey %>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="field">
|
|
19
|
+
<%= f.label :name %><br />
|
|
20
|
+
<%= f.text_field :name %>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="field">
|
|
23
|
+
<%= f.label :description %><br />
|
|
24
|
+
<%= f.text_area :description %>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="field">
|
|
27
|
+
<%= f.label :parent_fieldset_id %><br />
|
|
28
|
+
<%= f.select :parent_fieldset_id, options_for_select(DynamicFieldsets::Fieldset.parent_fieldset_list), :include_blank => "Choose One" %>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="field">
|
|
31
|
+
<%= f.label :order_num, "Order Number" %><br />
|
|
32
|
+
<%= f.text_field :order_num %>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="actions">
|
|
35
|
+
<%= f.submit %>
|
|
36
|
+
</div>
|
|
37
|
+
<% end %>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<h1>Listing fieldset children of <%= @parent_fieldset.name %></h1>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<th>Type</th>
|
|
6
|
+
<th>Order Number</th>
|
|
7
|
+
<th>Name</th>
|
|
8
|
+
<th>Description/Field Type</th>
|
|
9
|
+
<th>Fieldset Children</th>
|
|
10
|
+
<th></th>
|
|
11
|
+
<th></th>
|
|
12
|
+
<th></th>
|
|
13
|
+
</tr>
|
|
14
|
+
|
|
15
|
+
<% @fieldset_family.each do |child| %>
|
|
16
|
+
<% if child.is_a?(DynamicFieldsets::Fieldset) %>
|
|
17
|
+
<tr>
|
|
18
|
+
<td>Fieldset</td>
|
|
19
|
+
<td><%= child.order_num %></td>
|
|
20
|
+
<td><%= child.name %></td>
|
|
21
|
+
<td><%= child.description %></td>
|
|
22
|
+
<td><%= link_to 'Children', dynamic_fieldsets_children_dynamic_fieldsets_fieldset_path(child) %></td>
|
|
23
|
+
<td><%= link_to 'Show', dynamic_fieldsets_fieldset_path(child) %></td>
|
|
24
|
+
<td><%= link_to 'Edit', edit_dynamic_fieldsets_fieldset_path(child) %></td>
|
|
25
|
+
<td><%= link_to 'Destroy', dynamic_fieldsets_fieldset_path(child), :confirm => 'Are you sure?', :method => :delete %></td>
|
|
26
|
+
</tr>
|
|
27
|
+
<% elsif child.is_a?(DynamicFieldsets::Field) %>
|
|
28
|
+
<tr>
|
|
29
|
+
<td>Field</td>
|
|
30
|
+
<td><%= child.order_num %></td>
|
|
31
|
+
<td><%= child.name %></td>
|
|
32
|
+
<td><%= child.field_type %></td>
|
|
33
|
+
<td>N/A</td>
|
|
34
|
+
<td><%= link_to 'Show', dynamic_fieldsets_fieldset_path(child) %></td>
|
|
35
|
+
<td><%= link_to 'Edit', edit_dynamic_fieldsets_fieldset_path(child) %></td>
|
|
36
|
+
<td><%= link_to 'Destroy', dynamic_fieldsets_fieldset_path(child), :confirm => 'Are you sure?', :method => :delete %></td>
|
|
37
|
+
</tr>
|
|
38
|
+
<% end %>
|
|
39
|
+
<% end %>
|
|
40
|
+
|
|
41
|
+
</table>
|
|
42
|
+
|
|
43
|
+
<%= link_to 'Return to Main Show', dynamic_fieldsets_fieldset_path(@parent_fieldset) %>
|
|
44
|
+
|
|
45
|
+
<br />
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<h1>Listing fieldsets</h1>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<th>Nkey</th>
|
|
6
|
+
<th>Name</th>
|
|
7
|
+
<th>Description</th>
|
|
8
|
+
<th>Parent fieldset</th>
|
|
9
|
+
<th></th>
|
|
10
|
+
<th></th>
|
|
11
|
+
<th></th>
|
|
12
|
+
<th></th>
|
|
13
|
+
</tr>
|
|
14
|
+
|
|
15
|
+
<% @fieldsets.each do |fieldset| %>
|
|
16
|
+
<tr>
|
|
17
|
+
<td><%= fieldset.nkey %></td>
|
|
18
|
+
<td><%= fieldset.name %></td>
|
|
19
|
+
<td><%= fieldset.description %></td>
|
|
20
|
+
<td><%= fieldset.parent_fieldset_id %></td>
|
|
21
|
+
<td><%= link_to 'Children', dynamic_fieldsets_children_dynamic_fieldsets_fieldset_path(fieldset) %></td>
|
|
22
|
+
<td><%= link_to 'Show', dynamic_fieldsets_fieldset_path(fieldset) %></td>
|
|
23
|
+
<td><%= link_to 'Edit', edit_dynamic_fieldsets_fieldset_path(fieldset) %></td>
|
|
24
|
+
<td><%= link_to 'Destroy', dynamic_fieldsets_fieldset_path(fieldset), :confirm => 'Are you sure?', :method => :delete %></td>
|
|
25
|
+
</tr>
|
|
26
|
+
<% end %>
|
|
27
|
+
</table>
|
|
28
|
+
|
|
29
|
+
<br />
|
|
30
|
+
|
|
31
|
+
<%= link_to 'New Fieldset', new_dynamic_fieldsets_fieldset_path %>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
|
2
|
+
|
|
3
|
+
<p>
|
|
4
|
+
<b>Nkey:</b>
|
|
5
|
+
<%= @fieldset.nkey %>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p>
|
|
9
|
+
<b>Name:</b>
|
|
10
|
+
<%= @fieldset.name %>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p>
|
|
14
|
+
<b>Description:</b>
|
|
15
|
+
<%= @fieldset.description %>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<% if @fieldset.parent_fieldset %>
|
|
19
|
+
<p>
|
|
20
|
+
<b>Parent fieldset:</b>
|
|
21
|
+
<%= @fieldset.parent_fieldset.name %>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<p>
|
|
25
|
+
<b>Order num:</b>
|
|
26
|
+
<%= @fieldset.order_num %>
|
|
27
|
+
</p>
|
|
28
|
+
<% end %>
|
|
29
|
+
|
|
30
|
+
<%= link_to 'Edit', edit_dynamic_fieldsets_fieldset_path(@fieldset) %> |
|
|
31
|
+
<%= link_to 'Back', dynamic_fieldsets_fieldsets_path %>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = %q{dynamic_fieldsets}
|
|
8
|
+
s.version = "0.0.2"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = [%q{Jeremiah Hemphill}, %q{Ethan Pemble}]
|
|
12
|
+
s.date = %q{2011-07-28}
|
|
13
|
+
s.description = %q{Dynamic fieldsets for rails controllers}
|
|
14
|
+
s.email = %q{jeremiah@cloudspace.com}
|
|
15
|
+
s.extra_rdoc_files = [
|
|
16
|
+
"README.rdoc"
|
|
17
|
+
]
|
|
18
|
+
s.files = [
|
|
19
|
+
"CHANGELOG",
|
|
20
|
+
"Gemfile",
|
|
21
|
+
"Gemfile.lock",
|
|
22
|
+
"MIT-LICENSE",
|
|
23
|
+
"README.rdoc",
|
|
24
|
+
"Rakefile",
|
|
25
|
+
"VERSION",
|
|
26
|
+
"app/controllers/dynamic_fieldsets/fields_controller.rb",
|
|
27
|
+
"app/controllers/dynamic_fieldsets/fieldset_associators_controller.rb",
|
|
28
|
+
"app/controllers/dynamic_fieldsets/fieldsets_controller.rb",
|
|
29
|
+
"app/helpers/dynamic_fieldsets/fields_helper.rb",
|
|
30
|
+
"app/helpers/dynamic_fieldsets_helper.rb",
|
|
31
|
+
"app/models/dynamic_fieldsets/field.rb",
|
|
32
|
+
"app/models/dynamic_fieldsets/field_default.rb",
|
|
33
|
+
"app/models/dynamic_fieldsets/field_html_attribute.rb",
|
|
34
|
+
"app/models/dynamic_fieldsets/field_option.rb",
|
|
35
|
+
"app/models/dynamic_fieldsets/field_record.rb",
|
|
36
|
+
"app/models/dynamic_fieldsets/fieldset.rb",
|
|
37
|
+
"app/models/dynamic_fieldsets/fieldset_associator.rb",
|
|
38
|
+
"app/views/dynamic_fieldsets/fields/_field_default_fields.html.erb",
|
|
39
|
+
"app/views/dynamic_fieldsets/fields/_field_html_attribute_fields.html.erb",
|
|
40
|
+
"app/views/dynamic_fieldsets/fields/_field_option_fields.html.erb",
|
|
41
|
+
"app/views/dynamic_fieldsets/fields/_form.html.erb",
|
|
42
|
+
"app/views/dynamic_fieldsets/fields/edit.html.erb",
|
|
43
|
+
"app/views/dynamic_fieldsets/fields/index.html.erb",
|
|
44
|
+
"app/views/dynamic_fieldsets/fields/new.html.erb",
|
|
45
|
+
"app/views/dynamic_fieldsets/fields/show.html.erb",
|
|
46
|
+
"app/views/dynamic_fieldsets/fieldset_associators/index.html.erb",
|
|
47
|
+
"app/views/dynamic_fieldsets/fieldset_associators/show.html.erb",
|
|
48
|
+
"app/views/dynamic_fieldsets/fieldsets/_form.html.erb",
|
|
49
|
+
"app/views/dynamic_fieldsets/fieldsets/children.html.erb",
|
|
50
|
+
"app/views/dynamic_fieldsets/fieldsets/edit.html.erb",
|
|
51
|
+
"app/views/dynamic_fieldsets/fieldsets/index.html.erb",
|
|
52
|
+
"app/views/dynamic_fieldsets/fieldsets/new.html.erb",
|
|
53
|
+
"app/views/dynamic_fieldsets/fieldsets/show.html.erb",
|
|
54
|
+
"config/routes.rb",
|
|
55
|
+
"dynamic_fieldsets.gemspec",
|
|
56
|
+
"lib/dynamic_fieldsets.rb",
|
|
57
|
+
"lib/dynamic_fieldsets/config.rb",
|
|
58
|
+
"lib/dynamic_fieldsets/dynamic_fieldsets_in_model.rb",
|
|
59
|
+
"lib/dynamic_fieldsets/engine.rb",
|
|
60
|
+
"lib/dynamic_fieldsets/railtie.rb",
|
|
61
|
+
"lib/generators/dynamic_fieldsets/install_generator.rb",
|
|
62
|
+
"lib/generators/dynamic_fieldsets/templates/config.rb",
|
|
63
|
+
"lib/generators/dynamic_fieldsets/templates/migrations/install_migration.rb",
|
|
64
|
+
"spec/dummy/Rakefile",
|
|
65
|
+
"spec/dummy/app/controllers/application_controller.rb",
|
|
66
|
+
"spec/dummy/app/controllers/information_forms_controller.rb",
|
|
67
|
+
"spec/dummy/app/helpers/application_helper.rb",
|
|
68
|
+
"spec/dummy/app/helpers/information_forms_helper.rb",
|
|
69
|
+
"spec/dummy/app/models/information_form.rb",
|
|
70
|
+
"spec/dummy/app/views/information_forms/_form.html.erb",
|
|
71
|
+
"spec/dummy/app/views/information_forms/edit.html.erb",
|
|
72
|
+
"spec/dummy/app/views/information_forms/index.html.erb",
|
|
73
|
+
"spec/dummy/app/views/information_forms/new.html.erb",
|
|
74
|
+
"spec/dummy/app/views/information_forms/show.html.erb",
|
|
75
|
+
"spec/dummy/app/views/layouts/application.html.erb",
|
|
76
|
+
"spec/dummy/config.ru",
|
|
77
|
+
"spec/dummy/config/application.rb",
|
|
78
|
+
"spec/dummy/config/boot.rb",
|
|
79
|
+
"spec/dummy/config/database.yml",
|
|
80
|
+
"spec/dummy/config/environment.rb",
|
|
81
|
+
"spec/dummy/config/environments/development.rb",
|
|
82
|
+
"spec/dummy/config/environments/production.rb",
|
|
83
|
+
"spec/dummy/config/environments/test.rb",
|
|
84
|
+
"spec/dummy/config/initializers/backtrace_silencers.rb",
|
|
85
|
+
"spec/dummy/config/initializers/inflections.rb",
|
|
86
|
+
"spec/dummy/config/initializers/mime_types.rb",
|
|
87
|
+
"spec/dummy/config/initializers/secret_token.rb",
|
|
88
|
+
"spec/dummy/config/initializers/session_store.rb",
|
|
89
|
+
"spec/dummy/config/locales/en.yml",
|
|
90
|
+
"spec/dummy/config/routes.rb",
|
|
91
|
+
"spec/dummy/db/migrate/20110726215814_create_dynamic_fieldsets_tables.rb",
|
|
92
|
+
"spec/dummy/db/migrate/20110727210451_create_information_forms.rb",
|
|
93
|
+
"spec/dummy/db/schema.rb",
|
|
94
|
+
"spec/dummy/features/field.feature",
|
|
95
|
+
"spec/dummy/features/fieldset.feature",
|
|
96
|
+
"spec/dummy/features/fieldset_associator.feature",
|
|
97
|
+
"spec/dummy/features/step_definitions/debugging_steps.rb",
|
|
98
|
+
"spec/dummy/features/step_definitions/field_steps.rb",
|
|
99
|
+
"spec/dummy/features/step_definitions/fieldset_associator_steps.rb",
|
|
100
|
+
"spec/dummy/features/step_definitions/fieldset_steps.rb",
|
|
101
|
+
"spec/dummy/features/step_definitions/web_steps.rb",
|
|
102
|
+
"spec/dummy/features/support/env.rb",
|
|
103
|
+
"spec/dummy/features/support/paths.rb",
|
|
104
|
+
"spec/dummy/features/support/selectors.rb",
|
|
105
|
+
"spec/dummy/public/404.html",
|
|
106
|
+
"spec/dummy/public/422.html",
|
|
107
|
+
"spec/dummy/public/500.html",
|
|
108
|
+
"spec/dummy/public/favicon.ico",
|
|
109
|
+
"spec/dummy/public/javascripts/application.js",
|
|
110
|
+
"spec/dummy/public/javascripts/jquery.min.js",
|
|
111
|
+
"spec/dummy/public/stylesheets/.gitkeep",
|
|
112
|
+
"spec/dummy/public/stylesheets/scaffold.css",
|
|
113
|
+
"spec/dummy/script/rails",
|
|
114
|
+
"spec/dynamic_fieldsets_helper_spec.rb",
|
|
115
|
+
"spec/dynamic_fieldsets_in_model_spec.rb",
|
|
116
|
+
"spec/dynamic_fieldsets_spec.rb",
|
|
117
|
+
"spec/integration/navigation_spec.rb",
|
|
118
|
+
"spec/models/field_default_spec.rb",
|
|
119
|
+
"spec/models/field_html_attribute_spec.rb",
|
|
120
|
+
"spec/models/field_option_spec.rb",
|
|
121
|
+
"spec/models/field_record_spec.rb",
|
|
122
|
+
"spec/models/field_spec.rb",
|
|
123
|
+
"spec/models/fieldset_associator_spec.rb",
|
|
124
|
+
"spec/models/fieldset_spec.rb",
|
|
125
|
+
"spec/reports/SPEC-ActsAsMultipartForm.xml",
|
|
126
|
+
"spec/reports/SPEC-MultipartForm-InProgressForm-validations.xml",
|
|
127
|
+
"spec/reports/SPEC-MultipartForm-InProgressForm.xml",
|
|
128
|
+
"spec/reports/SPEC-Navigation.xml",
|
|
129
|
+
"spec/spec_helper.rb",
|
|
130
|
+
"spec/support/field_default_helper.rb",
|
|
131
|
+
"spec/support/field_helper.rb",
|
|
132
|
+
"spec/support/field_html_attribute_helper.rb",
|
|
133
|
+
"spec/support/field_option_helper.rb",
|
|
134
|
+
"spec/support/field_record_helper.rb",
|
|
135
|
+
"spec/support/fieldset_associator_helper.rb",
|
|
136
|
+
"spec/support/fieldset_helper.rb"
|
|
137
|
+
]
|
|
138
|
+
s.homepage = %q{http://github.com/jeremiahishere/dynamic_fieldsets}
|
|
139
|
+
s.licenses = [%q{MIT}]
|
|
140
|
+
s.require_paths = [%q{lib}]
|
|
141
|
+
s.rubygems_version = %q{1.8.5}
|
|
142
|
+
s.summary = %q{Dynamic fieldsets for rails controllers}
|
|
143
|
+
|
|
144
|
+
if s.respond_to? :specification_version then
|
|
145
|
+
s.specification_version = 3
|
|
146
|
+
|
|
147
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
148
|
+
s.add_runtime_dependency(%q<rails>, ["= 3.0.7"])
|
|
149
|
+
s.add_runtime_dependency(%q<capybara>, [">= 0.4.0"])
|
|
150
|
+
s.add_runtime_dependency(%q<sqlite3>, [">= 0"])
|
|
151
|
+
s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
|
|
152
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
|
|
153
|
+
s.add_development_dependency(%q<rspec-rails>, ["~> 2.6.1"])
|
|
154
|
+
s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
|
|
155
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
|
156
|
+
s.add_development_dependency(%q<cucumber-rails>, [">= 0"])
|
|
157
|
+
s.add_development_dependency(%q<database_cleaner>, [">= 0"])
|
|
158
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
159
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
|
|
160
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
|
161
|
+
s.add_development_dependency(%q<ci_reporter>, [">= 0"])
|
|
162
|
+
else
|
|
163
|
+
s.add_dependency(%q<rails>, ["= 3.0.7"])
|
|
164
|
+
s.add_dependency(%q<capybara>, [">= 0.4.0"])
|
|
165
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
|
166
|
+
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
|
167
|
+
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
|
168
|
+
s.add_dependency(%q<rspec-rails>, ["~> 2.6.1"])
|
|
169
|
+
s.add_dependency(%q<yard>, ["~> 0.6.0"])
|
|
170
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
|
171
|
+
s.add_dependency(%q<cucumber-rails>, [">= 0"])
|
|
172
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
|
173
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
174
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
|
|
175
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
176
|
+
s.add_dependency(%q<ci_reporter>, [">= 0"])
|
|
177
|
+
end
|
|
178
|
+
else
|
|
179
|
+
s.add_dependency(%q<rails>, ["= 3.0.7"])
|
|
180
|
+
s.add_dependency(%q<capybara>, [">= 0.4.0"])
|
|
181
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
|
182
|
+
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
|
183
|
+
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
|
184
|
+
s.add_dependency(%q<rspec-rails>, ["~> 2.6.1"])
|
|
185
|
+
s.add_dependency(%q<yard>, ["~> 0.6.0"])
|
|
186
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
|
187
|
+
s.add_dependency(%q<cucumber-rails>, [">= 0"])
|
|
188
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
|
189
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
190
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
|
|
191
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
192
|
+
s.add_dependency(%q<ci_reporter>, [">= 0"])
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
File without changes
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
module DynamicFieldsets
|
|
2
|
+
# Adds dynamic fieldsets to models.
|
|
3
|
+
# The configuration options here determine which fieldset is associated with the model
|
|
4
|
+
# and how it is identified. The model knows which fieldset it is suppoed to be
|
|
5
|
+
# associated with and where the values for the fieldset are stored.
|
|
6
|
+
module DynamicFieldsetsInModel
|
|
7
|
+
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.extend ClassMethods
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module ClassMethods
|
|
13
|
+
# Adds a dynamic fieldset to a model
|
|
14
|
+
#
|
|
15
|
+
# Each set of options should be put inside of a hash with the unqiue name for the
|
|
16
|
+
# fieldset as the key:
|
|
17
|
+
# :child_form => {options}
|
|
18
|
+
# Options:
|
|
19
|
+
# Fieldset: The unique name of the fieldset the class is associated with
|
|
20
|
+
# Multiple: Boolean value to allow multiple answer sets for the same fieldset in the class.
|
|
21
|
+
# Deafult to false. Not curently implemented (7-25-2011).
|
|
22
|
+
#
|
|
23
|
+
# @param [Hash] args A hash of arguments for the fieldsets.
|
|
24
|
+
def acts_as_dynamic_fieldset(args)
|
|
25
|
+
mattr_accessor :dynamic_fieldsets unless self.respond_to?(:dynamic_fieldsets)
|
|
26
|
+
self.dynamic_fieldsets = {} unless self.dynamic_fieldsets.is_a?(Hash)
|
|
27
|
+
|
|
28
|
+
args.each_pair do |key, value|
|
|
29
|
+
self.dynamic_fieldsets[key] = value
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# hacky system to save fieldset values
|
|
33
|
+
# needs to be refactored and tested
|
|
34
|
+
mattr_accessor :dynamic_fieldset_values unless self.respond_to?(:dynamic_fieldset_values)
|
|
35
|
+
after_save :save_dynamic_fieldsets
|
|
36
|
+
|
|
37
|
+
include DynamicFieldsets::DynamicFieldsetsInModel::InstanceMethods
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
module InstanceMethods
|
|
42
|
+
|
|
43
|
+
# hacky system to save fieldset values
|
|
44
|
+
# needs to be refactored and tested
|
|
45
|
+
#
|
|
46
|
+
# among other things, it can edit field records for random fsas if the wrong information comes from the controller
|
|
47
|
+
def save_dynamic_fieldsets
|
|
48
|
+
if !self.dynamic_fieldset_values.nil?
|
|
49
|
+
self.dynamic_fieldset_values.keys.each do |key|
|
|
50
|
+
if key.start_with?("fsa-")
|
|
51
|
+
key_id = key.gsub(/^fsa-/, "")
|
|
52
|
+
fsa = DynamicFieldsets::FieldsetAssociator.find_by_id(key_id)
|
|
53
|
+
self.dynamic_fieldset_values[key].keys.each do |sub_key|
|
|
54
|
+
if sub_key.start_with?("field-")
|
|
55
|
+
sub_key_id = sub_key.gsub(/^field-/, "")
|
|
56
|
+
field_record = DynamicFieldsets::FieldRecord.where(:fieldset_associator_id => fsa.id, :field_id => sub_key_id).first
|
|
57
|
+
if field_record.nil?
|
|
58
|
+
field_record = DynamicFieldsets::FieldRecord.create(:fieldset_associator_id => fsa.id, :field_id => sub_key_id, :value => self.dynamic_fieldset_values[key][sub_key])
|
|
59
|
+
else
|
|
60
|
+
field_record.value = self.dynamic_fieldset_values[key][sub_key]
|
|
61
|
+
field_record.save
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
self.dynamic_fieldset_values = nil
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Matches methods that match named_fieldset and named_fieldset_fieldset
|
|
72
|
+
# Or calls super
|
|
73
|
+
#
|
|
74
|
+
# @param [Symbol] sym The name of the method
|
|
75
|
+
# @param [Array] args The arguments of the method
|
|
76
|
+
# @returns [?] The result of the found method or the result of super
|
|
77
|
+
def method_missing(sym, *args)
|
|
78
|
+
if match_fieldset_associator?(sym)
|
|
79
|
+
return fieldset_associator(sym)
|
|
80
|
+
elsif match_fieldset?(sym)
|
|
81
|
+
return fieldset(sym)
|
|
82
|
+
else
|
|
83
|
+
super(sym, *args)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Matches methods that match named_fieldset and named_fieldset_fieldset
|
|
88
|
+
# Or calls super
|
|
89
|
+
#
|
|
90
|
+
# @param [Symbol] sym The name of the method
|
|
91
|
+
# @param [Array] args The arguments of the method
|
|
92
|
+
# @returns [Boolean] True if the method is found or the result of super
|
|
93
|
+
def respond_to?(sym, *args)
|
|
94
|
+
if match_fieldset_associator?(sym)
|
|
95
|
+
return true
|
|
96
|
+
elsif match_fieldset?(sym)
|
|
97
|
+
return true
|
|
98
|
+
else
|
|
99
|
+
super(sym, *args)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Returns whether a method name matches a named fieldset
|
|
104
|
+
#
|
|
105
|
+
# @param [Symbol] The name of the method
|
|
106
|
+
# @param [Boolean] Whether the method name matches a named fieldset
|
|
107
|
+
def match_fieldset_associator?(sym)
|
|
108
|
+
return self.dynamic_fieldsets.keys.include?(sym)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Returns whether a method name matches a named fieldset followed by '_fieldset'
|
|
112
|
+
#
|
|
113
|
+
# @param [Symbol] The name of the method
|
|
114
|
+
# @param [Boolean] Whether the method name matches a named fieldset
|
|
115
|
+
def match_fieldset?(sym)
|
|
116
|
+
sym_string = sym.to_s
|
|
117
|
+
if !sym_string.match(/_fieldset$/)
|
|
118
|
+
return false
|
|
119
|
+
else
|
|
120
|
+
sym_string.gsub!(/_fieldset$/, "")
|
|
121
|
+
return self.dynamic_fieldsets.keys.include?(sym_string.to_sym)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Returns the fieldset associator object for the named fieldset.
|
|
126
|
+
# If one doesn't exist, it creates it and returns it
|
|
127
|
+
#
|
|
128
|
+
# @param [Symbol] The name of the name fieldset
|
|
129
|
+
# @param [FieldsetAssociator] The fieldset associator object for the named fieldset
|
|
130
|
+
def fieldset_associator(sym)
|
|
131
|
+
if match_fieldset_associator?(sym)
|
|
132
|
+
fsa = DynamicFieldsets::FieldsetAssociator.find_by_fieldset_model_parameters(
|
|
133
|
+
:fieldset_model_id => self.id,
|
|
134
|
+
:fieldset_model_type => self.class.name,
|
|
135
|
+
:fieldset_model_name => sym,
|
|
136
|
+
:fieldset => self.dynamic_fieldsets[sym][:fieldset]).first
|
|
137
|
+
if fsa.nil?
|
|
138
|
+
fsa = DynamicFieldsets::FieldsetAssociator.create(
|
|
139
|
+
:fieldset_model_id => self.id,
|
|
140
|
+
:fieldset_model_type => self.class.name,
|
|
141
|
+
:fieldset_model_name => sym.to_s,
|
|
142
|
+
:fieldset => DynamicFieldsets::Fieldset.find_by_nkey(self.dynamic_fieldsets[sym][:fieldset]))
|
|
143
|
+
end
|
|
144
|
+
return fsa
|
|
145
|
+
else
|
|
146
|
+
return nil
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Returns the fieldset object for the named fieldset
|
|
151
|
+
#
|
|
152
|
+
# @param [Symbol] The name of the named fieldset
|
|
153
|
+
# @param [Fieldset] The fieldset object for the named fieldset
|
|
154
|
+
def fieldset(sym)
|
|
155
|
+
if match_fieldset_associator?(sym)
|
|
156
|
+
return DynamicFieldsets::Fieldset.find_by_nkey(:nkey => self.dynamic_fieldsets[sym][:fieldset])
|
|
157
|
+
else
|
|
158
|
+
return nil
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'rails'
|
|
2
|
+
|
|
3
|
+
# no configuration yet
|
|
4
|
+
require 'dynamic_fieldsets/config'
|
|
5
|
+
|
|
6
|
+
module DynamicFieldsets
|
|
7
|
+
class Railtie < ::Rails::Railtie
|
|
8
|
+
initializer 'dynamic_fieldsets' do |app|
|
|
9
|
+
require 'dynamic_fieldsets/dynamic_fieldsets_in_model'
|
|
10
|
+
ActiveRecord::Base.send :include, DynamicFieldsets::DynamicFieldsetsInModel
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|