dynamic_fieldsets 0.1.17 → 0.1.18
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 +1 -1
- data/app/helpers/dynamic_fieldsets_helper.rb +3 -3
- data/app/models/dynamic_fieldsets/fieldset_associator.rb +0 -5
- data/app/views/dynamic_fieldsets/fieldset_children/_dependency_fields.html.erb +1 -1
- data/app/views/dynamic_fieldsets/shared/_form_javascript_watcher.html.erb +67 -66
- data/app/views/dynamic_fieldsets/shared/_show_javascript_watcher.html.erb +23 -27
- data/dynamic_fieldsets.gemspec +4 -2
- data/spec/dummy/app/models/information_form.rb +1 -0
- data/spec/dummy/app/models/sub_form.rb +5 -0
- data/spec/dummy/app/views/information_forms/_form.html.erb +7 -1
- data/spec/dummy/app/views/information_forms/show.html.erb +4 -0
- data/spec/dummy/db/migrate/20130919203346_create_sub_forms.rb +14 -0
- data/spec/dummy/db/schema.rb +8 -1
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.18
|
@@ -116,14 +116,14 @@ module DynamicFieldsetsHelper
|
|
116
116
|
# @param [FieldsetAssociator] The fieldset associator for the dynamic fieldset to render
|
117
117
|
# @return [String] The HTML for the entire dynamic fieldset
|
118
118
|
def dynamic_fieldset_show_renderer(fsa)
|
119
|
-
return dynamic_fieldset_renderer(fsa, "show") << javascript_renderer("show"
|
119
|
+
return dynamic_fieldset_renderer(fsa, "show") << javascript_renderer(fsa,"show")
|
120
120
|
end
|
121
121
|
|
122
122
|
# Build HTML for a specific dynamic fieldset on a form page
|
123
123
|
# @param [FieldsetAssociator] The fieldset associator for the dynamic fieldset to render
|
124
124
|
# @return [String] The HTML for the entire dynamic fieldset
|
125
125
|
def dynamic_fieldset_form_renderer(fsa)
|
126
|
-
return dynamic_fieldset_renderer(fsa, "form") << javascript_renderer("form"
|
126
|
+
return dynamic_fieldset_renderer(fsa, "form") << javascript_renderer(fsa,"form")
|
127
127
|
end
|
128
128
|
|
129
129
|
# Builds HTML for a specific dynamic fieldset in a form.
|
@@ -145,7 +145,7 @@ module DynamicFieldsetsHelper
|
|
145
145
|
#
|
146
146
|
# @params [FieldsetAssociator] The fieldset associator for the dynamic fieldset to render
|
147
147
|
# @return [String] The javascript variable that shows what fields have dependencies
|
148
|
-
def javascript_renderer(
|
148
|
+
def javascript_renderer(fsa, form_type)
|
149
149
|
unless fsa.id == nil
|
150
150
|
rendered_javascript = "<script type='text/javascript'>
|
151
151
|
if ( typeof dynamic_fieldsets_dependencies == 'undefined' ){
|
@@ -86,11 +86,6 @@ module DynamicFieldsets
|
|
86
86
|
dependency_group = dependency.dependency_clause.dependency_group
|
87
87
|
output[fieldset_child.id][dependency_group.id] = dependency_group.to_hash
|
88
88
|
fieldset = dependency_group.fieldset_child.fieldset
|
89
|
-
if fieldset.fieldset_associators.collect(&:id).present?
|
90
|
-
output[fieldset_child.id][dependency_group.id][:fieldset_associators] = fieldset.fieldset_associators.collect(&:id)
|
91
|
-
else
|
92
|
-
output[fieldset_child.id][dependency_group.id][:fieldset_associators] = find_parent_fsa(fieldset).collect(&:id)
|
93
|
-
end
|
94
89
|
end
|
95
90
|
end
|
96
91
|
return output
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<tr>
|
2
|
-
<td><%= f.select :fieldset_child_id, options_for_select(
|
2
|
+
<td><%= f.select :fieldset_child_id, options_for_select(@fieldset_child.fieldset.fieldset_children.select { |x| x.child_type == "DynamicFieldsets::Field" && x.child.type != "DynamicFieldsets::InstructionField" }.collect { |c| [c.child.name, c.id]}, obj.fieldset_child_id)%></td>
|
3
3
|
<td><%= f.select :relationship, DynamicFieldsets::Dependency::RELATIONSHIP_LIST %></td>
|
4
4
|
<td><%= f.text_field :value %></td>
|
5
5
|
<td>
|
@@ -13,7 +13,7 @@ var all_inputs = $(":input:not(:hidden)[id^=fsa]").add("p[id^='fsa']").add("text
|
|
13
13
|
// return: The fieldset child id of the field
|
14
14
|
function get_fieldset_child_id(field, type) {
|
15
15
|
if(typeof(field.attr("data-fsc_id")) != "undefined") {
|
16
|
-
return field.attr("data-fsc_id")
|
16
|
+
return field.attr("data-fsc_id");
|
17
17
|
} else {
|
18
18
|
switch(type)
|
19
19
|
{
|
@@ -38,10 +38,10 @@ function get_fieldset_child_id(field, type) {
|
|
38
38
|
// And falls back on the the string between '-' and '_' at the beginning of the id
|
39
39
|
function get_fieldset_associator_id(field) {
|
40
40
|
if(typeof(field.attr("data-fsa_id")) != "undefined") {
|
41
|
-
return field.attr("data-fsa_id")
|
41
|
+
return field.attr("data-fsa_id");
|
42
42
|
} else {
|
43
43
|
//format should be fsa-###_field-###
|
44
|
-
return field.attr('id').split("_")[0].split("-")[1]
|
44
|
+
return field.attr('id').split("_")[0].split("-")[1];
|
45
45
|
}
|
46
46
|
}
|
47
47
|
|
@@ -62,7 +62,7 @@ function get_input_value(field, type) {
|
|
62
62
|
return output;
|
63
63
|
case 'checkbox':
|
64
64
|
return field.parent().parent().find(':checked').map(function(index,option) {
|
65
|
-
return $.trim($(option).parent('label').text())
|
65
|
+
return $.trim($(option).parent('label').text());
|
66
66
|
});
|
67
67
|
case 'select':
|
68
68
|
return field.find(':selected').text();
|
@@ -79,7 +79,7 @@ function get_input_value(field, type) {
|
|
79
79
|
//this code is necessary to handle text areas and multiple selects
|
80
80
|
function get_field_type(field) {
|
81
81
|
if (field.attr('type') != undefined) {
|
82
|
-
return field.attr('type')
|
82
|
+
return field.attr('type');
|
83
83
|
} else if ($('textarea#'+field.attr('id')).length > 0) {
|
84
84
|
return "textarea";
|
85
85
|
} else if ($('select#'+field.attr('id')).length > 0) {
|
@@ -102,19 +102,26 @@ function get_field_type(field) {
|
|
102
102
|
all_inputs.change( function() {
|
103
103
|
field = $(this);
|
104
104
|
var type = get_field_type(field);
|
105
|
-
var fieldset_child_id = get_fieldset_child_id(field, type)
|
105
|
+
var fieldset_child_id = get_fieldset_child_id(field, type);
|
106
106
|
|
107
|
-
var user_inputs = {}
|
107
|
+
var user_inputs = {};
|
108
108
|
$.each(all_inputs, function(index, input){
|
109
|
-
var
|
110
|
-
var
|
111
|
-
|
109
|
+
var each_type = get_field_type($(input));
|
110
|
+
var each_fieldset_child_id = get_fieldset_child_id($(input), each_type);
|
111
|
+
|
112
|
+
//checking if field is used has multiple associators to make a unique entry for each in user_inputs
|
113
|
+
if (each_fieldset_child_id in dynamic_fieldsets_dependencies) {
|
114
|
+
$.each(dynamic_fieldsets_dependencies[each_fieldset_child_id], function(index2, group) {
|
115
|
+
var each_fsa = $(input).attr('id').split("_")[0].split('-')[1]
|
116
|
+
user_inputs[each_fsa+"-"+each_fieldset_child_id] = get_input_value($(input), each_type);
|
117
|
+
});
|
118
|
+
}
|
112
119
|
});
|
113
120
|
|
114
121
|
if (fieldset_child_id in dynamic_fieldsets_dependencies) {
|
115
122
|
$.each(dynamic_fieldsets_dependencies[fieldset_child_id], function(index, group) {
|
116
|
-
|
117
|
-
update_dependency_group_for_fieldset_child(fieldset_child_id, group, user_inputs
|
123
|
+
var current_fsa = field.attr('id').split("_")[0].split('-')[1]
|
124
|
+
update_dependency_group_for_fieldset_child(fieldset_child_id, current_fsa, group, user_inputs);
|
118
125
|
});
|
119
126
|
}
|
120
127
|
});
|
@@ -122,24 +129,21 @@ all_inputs.change( function() {
|
|
122
129
|
// checks the clauses for a dependency group and runs the action
|
123
130
|
// group: the dependency group
|
124
131
|
// user_input: the input from the form
|
125
|
-
function update_dependency_group_for_fieldset_child(fieldset_child_id, group, user_inputs
|
132
|
+
function update_dependency_group_for_fieldset_child(fieldset_child_id, current_fsa, group, user_inputs) {
|
126
133
|
var action = group['action'];
|
127
134
|
var group_fsc_id = group['fieldset_child_id'];
|
128
135
|
var group_field_id = group['field_id'];
|
129
|
-
|
130
|
-
|
131
|
-
group_fields[index] = '<%= DynamicFieldsets.config.form_fieldset_associator_prefix %>' + fsa_id + '_' + '<%=DynamicFieldsets.config.form_field_prefix %>' + group_fsc_id;
|
132
|
-
});
|
133
|
-
dependency_action(all_dependency_clauses_true(fieldset_child_id, group, user_inputs), action, group_fields, 0 )
|
136
|
+
group_field = '<%= DynamicFieldsets.config.form_fieldset_associator_prefix %>' + current_fsa + '_' + '<%=DynamicFieldsets.config.form_field_prefix %>' + group_fsc_id;
|
137
|
+
dependency_action(all_dependency_clauses_true(fieldset_child_id, current_fsa, group, user_inputs), action, group_field);
|
134
138
|
}
|
135
139
|
|
136
140
|
//all dependencies clauses are ANDed
|
137
141
|
//the first one that is false makes this return false
|
138
142
|
//only return true if all return true
|
139
|
-
function all_dependency_clauses_true(fieldset_child_id, group, user_inputs) {
|
143
|
+
function all_dependency_clauses_true(fieldset_child_id, fieldset_associator, group, user_inputs) {
|
140
144
|
for(var key in group["clause"]) {
|
141
|
-
var clause = group["clause"][key]
|
142
|
-
if(!at_least_one_dependency_true(clause, user_inputs)) {
|
145
|
+
var clause = group["clause"][key];
|
146
|
+
if(!at_least_one_dependency_true(clause, user_inputs, fieldset_associator)) {
|
143
147
|
return false;
|
144
148
|
}
|
145
149
|
}
|
@@ -151,15 +155,15 @@ function all_dependency_clauses_true(fieldset_child_id, group, user_inputs) {
|
|
151
155
|
//Only return false if all are false
|
152
156
|
//It looks to see what dependencies inside the clause should actually be tested (AU 08-07-13)
|
153
157
|
// If dependency doesn't match current field, it looks up the correct stored input to compare
|
154
|
-
function at_least_one_dependency_true(clause, user_inputs) {
|
158
|
+
function at_least_one_dependency_true(clause, user_inputs, fieldset_associator) {
|
155
159
|
for(var key in clause) {
|
156
|
-
var dependency = clause[key]
|
157
|
-
var fieldset_child_id = dependency["fieldset_child_id"]
|
158
|
-
if( evaluate_dependency(user_inputs[fieldset_child_id], dependency["relationship"], dependency["value"]) ){
|
159
|
-
return true
|
160
|
+
var dependency = clause[key];
|
161
|
+
var fieldset_child_id = dependency["fieldset_child_id"];
|
162
|
+
if( evaluate_dependency(user_inputs[fieldset_associator+"-"+fieldset_child_id], dependency["relationship"], dependency["value"]) ){
|
163
|
+
return true;
|
160
164
|
}
|
161
165
|
}
|
162
|
-
return false
|
166
|
+
return false;
|
163
167
|
}
|
164
168
|
|
165
169
|
|
@@ -197,49 +201,46 @@ function evaluate_dependency(user_value, relationship, stored_value) {
|
|
197
201
|
// success_flag: whether the dependency group returned true or false
|
198
202
|
// action: the type of update to apply to the field
|
199
203
|
// group_field: the field to update (generally not the field that triggered the change)
|
200
|
-
function dependency_action(success_flag, action,
|
201
|
-
|
202
|
-
if
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
$('#' + group_field + ' :input').removeAttr('disabled');
|
210
|
-
}
|
211
|
-
|
212
|
-
} else {
|
213
|
-
switch(action)
|
214
|
-
{
|
215
|
-
case 'show':
|
216
|
-
$('[id$=' + group_field +']').hide();
|
217
|
-
case 'enable':
|
218
|
-
$('#' + group_field + ' :input').attr('disabled', true);
|
219
|
-
}
|
220
|
-
clear_unused_field(group_field)
|
221
|
-
|
222
|
-
nested_dependencies(success_flag, action, group_field)
|
204
|
+
function dependency_action(success_flag, action, group_field) {
|
205
|
+
if( $('[id$='+group_field+']').size() > 0 ) {
|
206
|
+
if (success_flag){
|
207
|
+
switch(action)
|
208
|
+
{
|
209
|
+
case 'show':
|
210
|
+
$('[id$=' + group_field +']').show();
|
211
|
+
case 'enable':
|
212
|
+
$('#' + group_field + ' :input').removeAttr('disabled');
|
223
213
|
}
|
214
|
+
|
215
|
+
} else {
|
216
|
+
switch(action)
|
217
|
+
{
|
218
|
+
case 'show':
|
219
|
+
$('[id$=' + group_field +']').hide();
|
220
|
+
case 'enable':
|
221
|
+
$('#' + group_field + ' :input').attr('disabled', true);
|
222
|
+
}
|
223
|
+
clear_unused_field(group_field);
|
224
|
+
|
225
|
+
nested_dependencies(success_flag, action, group_field);
|
224
226
|
}
|
225
|
-
}
|
227
|
+
}
|
226
228
|
};
|
227
229
|
|
228
230
|
//clears fields that are being hidden
|
229
231
|
function clear_unused_field(group_field) {
|
230
|
-
fields = $('[id$='+group_field+'] :input')
|
232
|
+
var fields = $('[id$='+group_field+'] :input');
|
231
233
|
fields.each( function(index, field) {
|
232
|
-
|
233
|
-
type = get_field_type(field);
|
234
|
+
type = get_field_type($(field));
|
234
235
|
switch(type)
|
235
236
|
{
|
236
237
|
case 'text':
|
237
238
|
case 'textarea':
|
238
|
-
field.val("");
|
239
|
+
$(field).val("");
|
239
240
|
case 'radio':
|
240
241
|
case 'checkbox':
|
241
|
-
if (field.attr('checked') == 'checked') {
|
242
|
-
field.removeAttr('checked')
|
242
|
+
if ($(field).attr('checked') == 'checked') {
|
243
|
+
$(field).removeAttr('checked');
|
243
244
|
}
|
244
245
|
case 'select':
|
245
246
|
case 'multi-select':
|
@@ -251,20 +252,20 @@ function clear_unused_field(group_field) {
|
|
251
252
|
function nested_dependencies(success_flag, action, group_field) {
|
252
253
|
var dependent_on = group_field.split("-").pop();
|
253
254
|
for( var key in dynamic_fieldsets_dependencies ) {
|
254
|
-
var child = dynamic_fieldsets_dependencies[key]
|
255
|
+
var child = dynamic_fieldsets_dependencies[key];
|
255
256
|
for( var keyg in child ) {
|
256
|
-
var group_search = child[keyg]
|
257
|
+
var group_search = child[keyg];
|
257
258
|
for( var keyc in group_search["clause"] ) {
|
258
|
-
var clause = group_search["clause"][keyc]
|
259
|
+
var clause = group_search["clause"][keyc];
|
259
260
|
for( var keyd in clause ) {
|
260
|
-
var dependency = clause[keyd]
|
261
|
+
var dependency = clause[keyd];
|
261
262
|
//select dependent by comparing who the dependency belongs to
|
262
263
|
if ( dependency["fieldset_child_id"] == dependent_on ) {
|
263
|
-
var fsa = group_field.split("_")[0]
|
264
|
-
var field = group_field.split("_")[1]
|
265
|
-
var dependent_id = field.replace(dependent_on, group_search["fieldset_child_id"])
|
266
|
-
var full_dep_id = fsa+"_"+dependent_id
|
267
|
-
dependency_action(success_flag, action, [full_dep_id])
|
264
|
+
var fsa = group_field.split("_")[0];
|
265
|
+
var field = group_field.split("_")[1];
|
266
|
+
var dependent_id = field.replace(dependent_on, group_search["fieldset_child_id"]);
|
267
|
+
var full_dep_id = fsa+"_"+dependent_id;
|
268
|
+
dependency_action(success_flag, action, [full_dep_id]);
|
268
269
|
}
|
269
270
|
}
|
270
271
|
}
|
@@ -1,22 +1,21 @@
|
|
1
1
|
<script type='text/javascript'>
|
2
2
|
|
3
|
-
var all_divs = $("div :not(:hidden)[id^=fsa]").add("p[id^='fsa']");
|
4
|
-
|
5
3
|
function hide_fields(){
|
6
|
-
var
|
4
|
+
var all_divs = $("div :not(:hidden)[id^=fsa]").add("p[id^='fsa']");
|
5
|
+
var values = {};
|
7
6
|
$.each(all_divs, function(index, div){
|
8
7
|
var div_id = $(div).attr('id');
|
9
8
|
var fieldset_child_id = div_id.substring(div_id.length-1);
|
10
|
-
var fsa_id = div_id.split("_")[0].split("-")[1]
|
9
|
+
var fsa_id = div_id.split("_")[0].split("-")[1];
|
11
10
|
|
12
11
|
if($(div).is("p")){
|
13
|
-
values[fieldset_child_id] = div.innerHTML
|
12
|
+
values[fieldset_child_id] = div.innerHTML;
|
14
13
|
} else {
|
15
14
|
if($(div).attr('type') == 'single'){
|
16
|
-
values[fieldset_child_id] = $(div).find('span').find('span').text()
|
15
|
+
values[fieldset_child_id] = $(div).find('span').find('span').text();
|
17
16
|
} else {
|
18
17
|
values[fieldset_child_id] = $(div).find('li').map(function(index, li){
|
19
|
-
return $(div).find('span').find('span').text()
|
18
|
+
return $(div).find('span').find('span').text();
|
20
19
|
});
|
21
20
|
}
|
22
21
|
}
|
@@ -25,7 +24,7 @@ function hide_fields(){
|
|
25
24
|
if((typeof dependency_group) != "undefined"){
|
26
25
|
$.each(dependency_group, function(index, group){
|
27
26
|
var fieldset_associator_ids = group['fieldset_associators'];
|
28
|
-
evaluate_dependencies(fieldset_child_id, group, values, fieldset_associator_ids)
|
27
|
+
evaluate_dependencies(fieldset_child_id, group, values, fieldset_associator_ids);
|
29
28
|
})
|
30
29
|
}
|
31
30
|
});
|
@@ -35,16 +34,16 @@ function evaluate_dependencies(fieldset_child_id, group, values, fieldset_associ
|
|
35
34
|
var action = group['action'];
|
36
35
|
var group_fsc_id = group['fieldset_child_id'];
|
37
36
|
var group_field_id = group['field_id'];
|
38
|
-
var group_fields = []
|
37
|
+
var group_fields = [];
|
39
38
|
$.each(fieldset_associator_ids, function(index, fsa_id) {
|
40
39
|
group_fields[index] = '<%= DynamicFieldsets.config.form_fieldset_associator_prefix %>' + fsa_id + '_' + '<%=DynamicFieldsets.config.form_field_prefix %>' + group_fsc_id;
|
41
40
|
});
|
42
|
-
dependency_action(all_dependency_clauses_true(fieldset_child_id, group, values), action, group_fields, 0 )
|
41
|
+
dependency_action(all_dependency_clauses_true(fieldset_child_id, group, values), action, group_fields, 0 );
|
43
42
|
}
|
44
43
|
|
45
44
|
function all_dependency_clauses_true(fieldset_child_id, group, values) {
|
46
45
|
for(var key in group["clause"]) {
|
47
|
-
var clause = group["clause"][key]
|
46
|
+
var clause = group["clause"][key];
|
48
47
|
if(!at_least_one_dependency_true(clause, values)) {
|
49
48
|
return false;
|
50
49
|
}
|
@@ -54,13 +53,13 @@ function all_dependency_clauses_true(fieldset_child_id, group, values) {
|
|
54
53
|
|
55
54
|
function at_least_one_dependency_true(clause, values) {
|
56
55
|
for(var key in clause) {
|
57
|
-
var dependency = clause[key]
|
58
|
-
var fieldset_child_id = dependency["fieldset_child_id"]
|
56
|
+
var dependency = clause[key];
|
57
|
+
var fieldset_child_id = dependency["fieldset_child_id"];
|
59
58
|
if( evaluate_dependency(values[fieldset_child_id], dependency["relationship"], dependency["value"]) ){
|
60
|
-
return true
|
59
|
+
return true;
|
61
60
|
}
|
62
61
|
}
|
63
|
-
return false
|
62
|
+
return false;
|
64
63
|
}
|
65
64
|
|
66
65
|
function evaluate_dependency(user_value, relationship, stored_value) {
|
@@ -105,7 +104,7 @@ function dependency_action(success_flag, action, group_fields, counter) {
|
|
105
104
|
|
106
105
|
//save from infinite recursion, only goes as deep as there are dependency groups
|
107
106
|
if( counter < Object.keys(dynamic_fieldsets_dependencies).length ) {
|
108
|
-
nested_dependencies(success_flag, action, group_field, counter)
|
107
|
+
nested_dependencies(success_flag, action, group_field, counter);
|
109
108
|
}
|
110
109
|
}
|
111
110
|
});
|
@@ -116,17 +115,14 @@ function nested_dependencies(success_flag, action, group_field, counter) {
|
|
116
115
|
for( var key in dynamic_fieldsets_dependencies ) {
|
117
116
|
var child = dynamic_fieldsets_dependencies[key]
|
118
117
|
for( var keyg in child ) {
|
119
|
-
|
120
|
-
|
121
|
-
var
|
122
|
-
for( var
|
123
|
-
var
|
124
|
-
|
125
|
-
var
|
126
|
-
|
127
|
-
var dependent_id = group_field.replace(dependent_on, group_search["fieldset_child_id"])
|
128
|
-
dependency_action(success_flag, action, [dependent_id], counter+1)
|
129
|
-
}
|
118
|
+
var group_search = child[keyg];
|
119
|
+
for( var keyc in group_search["clause"] ) {
|
120
|
+
var clause = group_search["clause"][keyc];
|
121
|
+
for( var keyd in clause ) {
|
122
|
+
var dependency = clause[keyd];
|
123
|
+
if ( dependency["fieldset_child_id"] == dependent_on ) {
|
124
|
+
var dependent_id = group_field.replace(dependent_on, group_search["fieldset_child_id"])
|
125
|
+
dependency_action(success_flag, action, [dependent_id], counter+1);
|
130
126
|
}
|
131
127
|
}
|
132
128
|
}
|
data/dynamic_fieldsets.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "dynamic_fieldsets"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.18"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeremiah Hemphill", "Ethan Pemble", "John Carter"]
|
12
|
-
s.date = "2013-09-
|
12
|
+
s.date = "2013-09-20"
|
13
13
|
s.description = "Dynamic fieldsets for rails controllers"
|
14
14
|
s.email = "jeremiah@cloudspace.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -124,6 +124,7 @@ Gem::Specification.new do |s|
|
|
124
124
|
"spec/dummy/app/helpers/application_helper.rb",
|
125
125
|
"spec/dummy/app/helpers/information_forms_helper.rb",
|
126
126
|
"spec/dummy/app/models/information_form.rb",
|
127
|
+
"spec/dummy/app/models/sub_form.rb",
|
127
128
|
"spec/dummy/app/views/information_forms/_form.html.erb",
|
128
129
|
"spec/dummy/app/views/information_forms/dynamic_view.html.erb",
|
129
130
|
"spec/dummy/app/views/information_forms/edit.html.erb",
|
@@ -149,6 +150,7 @@ Gem::Specification.new do |s|
|
|
149
150
|
"spec/dummy/config/routes.rb",
|
150
151
|
"spec/dummy/db/migrate/20110727210451_create_information_forms.rb",
|
151
152
|
"spec/dummy/db/migrate/20120213211033_create_dynamic_fieldsets_tables.rb",
|
153
|
+
"spec/dummy/db/migrate/20130919203346_create_sub_forms.rb",
|
152
154
|
"spec/dummy/db/schema.rb",
|
153
155
|
"spec/dummy/features/field.feature",
|
154
156
|
"spec/dummy/features/fieldset.feature",
|
@@ -1,4 +1,5 @@
|
|
1
1
|
class InformationForm < ActiveRecord::Base
|
2
|
+
has_many :sub_forms
|
2
3
|
# important note: for this to work, there needs to have a fieldset with an nkey of "first" in the db
|
3
4
|
# so that DynamicFieldsets::Fieldset.find_by_nkey("first") returns a fieldset
|
4
5
|
acts_as_dynamic_fieldset :child_form => {:fieldset => :first, :initialize_on_create => true}
|
@@ -15,9 +15,15 @@
|
|
15
15
|
<%= f.label :name %><br />
|
16
16
|
<%= f.text_field :name %>
|
17
17
|
</div>
|
18
|
+
|
18
19
|
<%= dynamic_fieldset_form_renderer(@information_form.child_form) %>
|
19
20
|
<%= dynamic_fieldset_form_renderer(@information_form.child_form2) %>
|
20
|
-
|
21
|
+
|
22
|
+
<% @information_form.sub_forms.each do |sub| %>
|
23
|
+
<%= dynamic_fieldset_form_renderer(sub.child_form3) %>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<div class="actions">
|
21
27
|
<%= f.submit %>
|
22
28
|
</div>
|
23
29
|
<% end %>
|
@@ -9,5 +9,9 @@
|
|
9
9
|
<%= dynamic_fieldset_show_renderer(@information_form.child_form) %>
|
10
10
|
<%= dynamic_fieldset_show_renderer(@information_form.child_form2) %>
|
11
11
|
|
12
|
+
<% @information_form.sub_forms.each do |sub| %>
|
13
|
+
<%= dynamic_fieldset_show_renderer(sub.child_form3) %>
|
14
|
+
<% end %>
|
15
|
+
|
12
16
|
<%= link_to 'Edit', edit_information_form_path(@information_form) %> |
|
13
17
|
<%= link_to 'Back', information_forms_path %>
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended to check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(:version =>
|
14
|
+
ActiveRecord::Schema.define(:version => 20130919203346) do
|
15
15
|
|
16
16
|
create_table "dynamic_fieldsets_dependencies", :force => true do |t|
|
17
17
|
t.integer "fieldset_child_id"
|
@@ -132,4 +132,11 @@ ActiveRecord::Schema.define(:version => 20120213211033) do
|
|
132
132
|
t.datetime "updated_at"
|
133
133
|
end
|
134
134
|
|
135
|
+
create_table "sub_forms", :force => true do |t|
|
136
|
+
t.string "name"
|
137
|
+
t.integer "information_form_id"
|
138
|
+
t.datetime "created_at"
|
139
|
+
t.datetime "updated_at"
|
140
|
+
end
|
141
|
+
|
135
142
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_fieldsets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-09-
|
14
|
+
date: 2013-09-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -416,6 +416,7 @@ files:
|
|
416
416
|
- spec/dummy/app/helpers/application_helper.rb
|
417
417
|
- spec/dummy/app/helpers/information_forms_helper.rb
|
418
418
|
- spec/dummy/app/models/information_form.rb
|
419
|
+
- spec/dummy/app/models/sub_form.rb
|
419
420
|
- spec/dummy/app/views/information_forms/_form.html.erb
|
420
421
|
- spec/dummy/app/views/information_forms/dynamic_view.html.erb
|
421
422
|
- spec/dummy/app/views/information_forms/edit.html.erb
|
@@ -441,6 +442,7 @@ files:
|
|
441
442
|
- spec/dummy/config/routes.rb
|
442
443
|
- spec/dummy/db/migrate/20110727210451_create_information_forms.rb
|
443
444
|
- spec/dummy/db/migrate/20120213211033_create_dynamic_fieldsets_tables.rb
|
445
|
+
- spec/dummy/db/migrate/20130919203346_create_sub_forms.rb
|
444
446
|
- spec/dummy/db/schema.rb
|
445
447
|
- spec/dummy/features/field.feature
|
446
448
|
- spec/dummy/features/fieldset.feature
|
@@ -521,7 +523,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
521
523
|
version: '0'
|
522
524
|
segments:
|
523
525
|
- 0
|
524
|
-
hash: -
|
526
|
+
hash: -1294392816585476854
|
525
527
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
526
528
|
none: false
|
527
529
|
requirements:
|