active_scaffold 3.2.7 → 3.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +16 -1
- data/app/assets/javascripts/jquery/active_scaffold.js +50 -16
- data/app/assets/javascripts/jquery/jquery.editinplace.js +6 -6
- data/app/assets/javascripts/prototype/active_scaffold.js +39 -15
- data/app/assets/stylesheets/active_scaffold_layout.css +24 -1
- data/frontends/default/views/_base_form.html.erb +9 -10
- data/frontends/default/views/_form.html.erb +8 -7
- data/frontends/default/views/_form_attribute.html.erb +6 -3
- data/frontends/default/views/_form_messages.html.erb +3 -3
- data/frontends/default/views/_horizontal_subform_record.html.erb +1 -1
- data/frontends/default/views/_list_calculations.html.erb +1 -1
- data/frontends/default/views/_list_messages.html.erb +10 -13
- data/frontends/default/views/_list_record_columns.html.erb +2 -2
- data/frontends/default/views/_messages.html.erb +1 -1
- data/frontends/default/views/_refresh_list.js.erb +1 -0
- data/frontends/default/views/_row.html.erb +2 -2
- data/frontends/default/views/_search.html.erb +2 -2
- data/frontends/default/views/_update_calculations.js.erb +4 -0
- data/frontends/default/views/_update_messages.js.erb +2 -0
- data/frontends/default/views/_vertical_subform_record.html.erb +1 -1
- data/frontends/default/views/add_existing.js.erb +2 -6
- data/frontends/default/views/destroy.js.erb +25 -23
- data/frontends/default/views/on_action_update.js.erb +21 -12
- data/frontends/default/views/on_create.js.erb +24 -21
- data/frontends/default/views/on_update.js.erb +19 -18
- data/frontends/default/views/refresh_list.js.erb +2 -1
- data/frontends/default/views/row.js.erb +1 -0
- data/frontends/default/views/update_column.js.erb +14 -15
- data/lib/active_scaffold.rb +1 -1
- data/lib/active_scaffold/actions/core.rb +6 -2
- data/lib/active_scaffold/actions/create.rb +9 -12
- data/lib/active_scaffold/actions/delete.rb +1 -4
- data/lib/active_scaffold/actions/list.rb +15 -12
- data/lib/active_scaffold/actions/mark.rb +1 -2
- data/lib/active_scaffold/actions/nested.rb +2 -1
- data/lib/active_scaffold/actions/update.rb +5 -8
- data/lib/active_scaffold/config/list.rb +18 -0
- data/lib/active_scaffold/constraints.rb +2 -12
- data/lib/active_scaffold/data_structures/column.rb +5 -2
- data/lib/active_scaffold/data_structures/nested_info.rb +6 -5
- data/lib/active_scaffold/finder.rb +11 -7
- data/lib/active_scaffold/helpers/controller_helpers.rb +16 -6
- data/lib/active_scaffold/helpers/form_column_helpers.rb +10 -20
- data/lib/active_scaffold/helpers/id_helpers.rb +2 -2
- data/lib/active_scaffold/helpers/list_column_helpers.rb +15 -20
- data/lib/active_scaffold/helpers/search_column_helpers.rb +15 -27
- data/lib/active_scaffold/helpers/show_column_helpers.rb +9 -20
- data/lib/active_scaffold/helpers/view_helpers.rb +20 -1
- data/lib/active_scaffold/version.rb +1 -1
- metadata +8 -4
data/CHANGELOG
CHANGED
@@ -1,4 +1,19 @@
|
|
1
|
-
= 3.2.
|
1
|
+
= 3.2.8 (not released)
|
2
|
+
- add deprecation for update_column, update_columns should be used instead
|
3
|
+
- fix constraints with hide_nested_column disabled in list and embedded scaffolds which are nested too
|
4
|
+
- fix setting a hash as includes, cannot be concat in finder
|
5
|
+
- add option to scroll on close only if element is not visible in viewport (default now)
|
6
|
+
- fix create and edit singular associations without render_component
|
7
|
+
- messages go across all table
|
8
|
+
- display readonly associations in forms, it was ready to display them but it was skipping them
|
9
|
+
- Some fixes for inplace editors (cloning form overrides, ajax and radiobuttons). Add handlers for empty columns
|
10
|
+
- add wrap_tag to list so cells content can be wrapped in a tag for better styling
|
11
|
+
- fix date picker parsing for datetime fields when jquery is used
|
12
|
+
- add as:element_updated js event when replace or replace_html is called
|
13
|
+
- rescue database exceptions so you get error messages for it insted of error 500, for example in case you forgot to check uniqueness for a unique index
|
14
|
+
- add class attribute for displayed unauthorized columns in forms, so they get same styling
|
15
|
+
|
16
|
+
= 3.2.7
|
2
17
|
- restore missing update.persistent feature
|
3
18
|
- fix create.persistent
|
4
19
|
- add new record in first scaffold, not in all nested scaffolds
|
@@ -111,18 +111,23 @@ jQuery(document).ready(function() {
|
|
111
111
|
ActiveScaffold.report_500_response(as_scaffold);
|
112
112
|
return true;
|
113
113
|
});
|
114
|
-
jQuery('
|
115
|
-
jQuery(this)
|
114
|
+
jQuery('td.in_place_editor_field').live('hover', function(event) {
|
115
|
+
var td = jQuery(this), span = td.find('span.in_place_editor_field');
|
116
|
+
span.data(); // $ 1.4.2 workaround
|
116
117
|
if (event.type == 'mouseenter') {
|
117
|
-
if (typeof(
|
118
|
+
if (td.hasClass('empty') || typeof(span.data('editInPlace')) === 'undefined') td.find('span').addClass("hover");
|
118
119
|
}
|
119
120
|
if (event.type == 'mouseleave') {
|
120
|
-
if (typeof(
|
121
|
+
if (td.hasClass('empty') || typeof(span.data('editInPlace')) === 'undefined') td.find('span').removeClass("hover");
|
121
122
|
}
|
122
123
|
return true;
|
123
124
|
});
|
124
|
-
jQuery('
|
125
|
-
|
125
|
+
jQuery('td.in_place_editor_field').live('click', function(event) {
|
126
|
+
var span = jQuery(this).find('span.in_place_editor_field');
|
127
|
+
span.data('addEmptyOnCancel', jQuery(this).hasClass('empty'));
|
128
|
+
jQuery(this).removeClass('empty');
|
129
|
+
if (span.data('editInPlace')) span.trigger('click.editInPlace');
|
130
|
+
else ActiveScaffold.in_place_editor_field_clicked(span);
|
126
131
|
});
|
127
132
|
jQuery('a.as_paginate').live('ajax:before',function(event) {
|
128
133
|
var as_paginate = jQuery(this);
|
@@ -201,6 +206,11 @@ jQuery(document).ready(function() {
|
|
201
206
|
}
|
202
207
|
return true;
|
203
208
|
});
|
209
|
+
|
210
|
+
jQuery('.message a.close').live('click', function(e) {
|
211
|
+
ActiveScaffold.hide(jQuery(this).closest('.message'));
|
212
|
+
e.preventDefault();
|
213
|
+
});
|
204
214
|
});
|
205
215
|
|
206
216
|
/* Simple Inheritance
|
@@ -361,9 +371,12 @@ var ActiveScaffold = {
|
|
361
371
|
},
|
362
372
|
reload_if_empty: function(tbody, url) {
|
363
373
|
if (this.records_for(tbody).length == 0) {
|
364
|
-
|
374
|
+
this.reload(url);
|
365
375
|
}
|
366
376
|
},
|
377
|
+
reload: function(url) {
|
378
|
+
jQuery.getScript(url);
|
379
|
+
},
|
367
380
|
removeSortClasses: function(scaffold) {
|
368
381
|
if (typeof(scaffold) == 'string') scaffold = '#' + scaffold;
|
369
382
|
scaffold = jQuery(scaffold)
|
@@ -409,6 +422,7 @@ var ActiveScaffold = {
|
|
409
422
|
if (element.attr('id')) {
|
410
423
|
element = jQuery('#' + element.attr('id'));
|
411
424
|
}
|
425
|
+
element.trigger('as:element_updated');
|
412
426
|
return element;
|
413
427
|
},
|
414
428
|
|
@@ -416,6 +430,7 @@ var ActiveScaffold = {
|
|
416
430
|
if (typeof(element) == 'string') element = '#' + element;
|
417
431
|
element = jQuery(element);
|
418
432
|
element.html(html);
|
433
|
+
element.trigger('as:element_updated');
|
419
434
|
return element;
|
420
435
|
},
|
421
436
|
|
@@ -423,6 +438,12 @@ var ActiveScaffold = {
|
|
423
438
|
if (typeof(element) == 'string') element = '#' + element;
|
424
439
|
jQuery(element).remove();
|
425
440
|
},
|
441
|
+
|
442
|
+
update_inplace_edit: function(element, value, empty) {
|
443
|
+
if (typeof(element) == 'string') element = '#' + element;
|
444
|
+
this.replace_html(jQuery(element), value);
|
445
|
+
if (empty) jQuery(element).closest('td').addClass('empty');
|
446
|
+
},
|
426
447
|
|
427
448
|
hide: function(element) {
|
428
449
|
if (typeof(element) == 'string') element = '#' + element;
|
@@ -528,15 +549,22 @@ var ActiveScaffold = {
|
|
528
549
|
|
529
550
|
find_action_link: function(element) {
|
530
551
|
if (typeof(element) == 'string') element = '#' + element;
|
531
|
-
|
532
|
-
return ActiveScaffold.ActionLink.get(as_adapter);
|
552
|
+
element = jQuery(element);
|
553
|
+
return ActiveScaffold.ActionLink.get(element.is('.actions a') ? element : element.closest('.as_adapter'));
|
533
554
|
},
|
534
555
|
|
535
|
-
scroll_to: function(element) {
|
556
|
+
scroll_to: function(element, checkInViewport) {
|
557
|
+
if (typeof checkInViewport == 'undefined') checkInViewport = true;
|
536
558
|
if (typeof(element) == 'string') element = '#' + element;
|
537
|
-
var form_offset = jQuery(element).offset()
|
538
|
-
|
539
|
-
|
559
|
+
var form_offset = jQuery(element).offset().top;
|
560
|
+
if (checkInViewport) {
|
561
|
+
var docViewTop = jQuery(window).scrollTop(),
|
562
|
+
docViewBottom = docViewTop + jQuery(window).height();
|
563
|
+
// If it's in viewport , don't scroll;
|
564
|
+
if (form_offset + jQuery(element).height() <= docViewBottom && form_offset >= docViewTop) return;
|
565
|
+
}
|
566
|
+
|
567
|
+
jQuery(document).scrollTop(form_offset);
|
540
568
|
},
|
541
569
|
|
542
570
|
process_checkbox_inplace_edit: function(checkbox, options) {
|
@@ -679,11 +707,17 @@ var ActiveScaffold = {
|
|
679
707
|
|
680
708
|
in_place_editor_field_clicked: function(span) {
|
681
709
|
span.data(); // $ 1.4.2 workaround
|
710
|
+
// test editor is open
|
682
711
|
if (typeof(span.data('editInPlace')) === 'undefined') {
|
683
712
|
var options = {show_buttons: true,
|
684
713
|
hover_class: 'hover',
|
685
714
|
element_id: 'editor_id',
|
686
715
|
ajax_data_type: "script",
|
716
|
+
delegate: {
|
717
|
+
willCloseEditInPlace: function(span, options, enteredText) {
|
718
|
+
if (span.data('addEmptyOnCancel')) span.closest('td').addClass('empty');
|
719
|
+
}
|
720
|
+
},
|
687
721
|
update_value: 'value'},
|
688
722
|
csrf_param = jQuery('meta[name=csrf-param]').first(),
|
689
723
|
csrf_token = jQuery('meta[name=csrf-token]').first(),
|
@@ -691,7 +725,7 @@ var ActiveScaffold = {
|
|
691
725
|
column_heading = null;
|
692
726
|
|
693
727
|
if(!(my_parent.is('td') || my_parent.is('th'))){
|
694
|
-
|
728
|
+
my_parent = span.parents('td').eq(0);
|
695
729
|
}
|
696
730
|
|
697
731
|
if (my_parent.is('td')) {
|
@@ -897,7 +931,7 @@ ActiveScaffold.ActionLink.Abstract = Class.extend({
|
|
897
931
|
this.enable();
|
898
932
|
this.adapter.remove();
|
899
933
|
if (this.hide_target) this.target.show();
|
900
|
-
if (ActiveScaffold.config.scroll_on_close) ActiveScaffold.scroll_to(this.target);
|
934
|
+
if (ActiveScaffold.config.scroll_on_close) ActiveScaffold.scroll_to(this.target, ActiveScaffold.config.scroll_on_close == 'checkInViewport');
|
901
935
|
},
|
902
936
|
|
903
937
|
get_new_adapter_id: function() {
|
@@ -991,10 +1025,10 @@ ActiveScaffold.ActionLink.Record = ActiveScaffold.ActionLink.Abstract.extend({
|
|
991
1025
|
},
|
992
1026
|
|
993
1027
|
close: function(refreshed_content) {
|
1028
|
+
this._super();
|
994
1029
|
if (refreshed_content) {
|
995
1030
|
ActiveScaffold.update_row(this.target, refreshed_content);
|
996
1031
|
}
|
997
|
-
this._super();
|
998
1032
|
},
|
999
1033
|
|
1000
1034
|
enable: function() {
|
@@ -285,6 +285,7 @@ $.extend(InlineEditor.prototype, {
|
|
285
285
|
},
|
286
286
|
|
287
287
|
setInitialValue: function() {
|
288
|
+
if (this.settings.field_type == 'remote') return; // remote generated editor doesn't need initial value
|
288
289
|
var initialValue = this.triggerDelegateCall('willOpenEditInPlace', this.originalValue);
|
289
290
|
var editor = this.dom.find(':input');
|
290
291
|
editor.val(initialValue);
|
@@ -312,7 +313,7 @@ $.extend(InlineEditor.prototype, {
|
|
312
313
|
|
313
314
|
var editorNode = patternNodes.editNode.clone();
|
314
315
|
var clonedNodes = null;
|
315
|
-
if (editorNode.attr('id')
|
316
|
+
if (editorNode.attr('id')) editorNode.attr('id', editorNode.attr('id') + this.settings.clone_id_suffix);
|
316
317
|
editorNode.attr('name', 'inplace_value');
|
317
318
|
editorNode.addClass('editor_field');
|
318
319
|
this.setValue(editorNode, this.originalValue);
|
@@ -321,7 +322,7 @@ $.extend(InlineEditor.prototype, {
|
|
321
322
|
if (patternNodes.additionalNodes) {
|
322
323
|
patternNodes.additionalNodes.each(function (index, node) {
|
323
324
|
var patternNode = $(node).clone();
|
324
|
-
if (patternNode.attr('id')
|
325
|
+
if (patternNode.attr('id')) {
|
325
326
|
patternNode.attr('id', patternNode.attr('id') + this.settings.clone_id_suffix);
|
326
327
|
}
|
327
328
|
clonedNodes = clonedNodes.after(patternNode);
|
@@ -342,8 +343,7 @@ $.extend(InlineEditor.prototype, {
|
|
342
343
|
selectedNodes = firstNode.children();
|
343
344
|
}
|
344
345
|
nodes.editNode = selectedNodes.first();
|
345
|
-
|
346
|
-
//nodes.additionalNodes = selectedNodes.find(':gt(0)');
|
346
|
+
nodes.additionalNodes = selectedNodes.slice(1);
|
347
347
|
}
|
348
348
|
return nodes;
|
349
349
|
},
|
@@ -470,10 +470,10 @@ $.extend(InlineEditor.prototype, {
|
|
470
470
|
if (false === this.triggerDelegateCall('shouldCloseEditInPlace', true, anEvent))
|
471
471
|
return;
|
472
472
|
|
473
|
-
var editor = this.dom.find(':input:not(:button)');
|
473
|
+
var editor = this.dom.find(':input:not(:button)').not('input:checkbox:not(:checked)').not('input:radio:not(:checked)');
|
474
474
|
var enteredText = '';
|
475
475
|
if (editor.length > 1) {
|
476
|
-
enteredText = jQuery.map(editor
|
476
|
+
enteredText = jQuery.map(editor, function(item, index) {
|
477
477
|
return $(item).val();
|
478
478
|
});
|
479
479
|
} else {
|
@@ -135,14 +135,16 @@ document.observe("dom:loaded", function() {
|
|
135
135
|
ActiveScaffold.report_500_response(as_scaffold);
|
136
136
|
return true;
|
137
137
|
});
|
138
|
-
document.on('mouseover', '
|
139
|
-
event.findElement().
|
138
|
+
document.on('mouseover', 'td.in_place_editor_field', function(event) {
|
139
|
+
event.findElement('td.in_place_editor_field').select('span').invoke('addClassName', 'hover');
|
140
140
|
});
|
141
|
-
document.on('mouseout', '
|
142
|
-
event.findElement().
|
141
|
+
document.on('mouseout', 'td.in_place_editor_field', function(event) {
|
142
|
+
event.findElement('td.in_place_editor_field').select('span').invoke('removeClassName', 'hover');
|
143
143
|
});
|
144
|
-
document.on('click', '
|
145
|
-
var
|
144
|
+
document.on('click', 'td.in_place_editor_field', function(event) {
|
145
|
+
var td = event.findElement('td.in_place_editor_field'),
|
146
|
+
span = td.down('span.in_place_editor_field');
|
147
|
+
td.removeClassName('empty');
|
146
148
|
|
147
149
|
if (typeof(span.inplace_edit) === 'undefined') {
|
148
150
|
var options = {htmlResponse: false,
|
@@ -150,6 +152,7 @@ document.observe("dom:loaded", function() {
|
|
150
152
|
onLeaveHover: null,
|
151
153
|
onComplete: null,
|
152
154
|
params: '',
|
155
|
+
externalControl: td.down('.handle'),
|
153
156
|
ajaxOptions: {method: 'post'}},
|
154
157
|
csrf_param = $$('meta[name=csrf-param]')[0],
|
155
158
|
csrf_token = $$('meta[name=csrf-token]')[0],
|
@@ -287,6 +290,10 @@ document.observe("dom:loaded", function() {
|
|
287
290
|
}
|
288
291
|
return true;
|
289
292
|
});
|
293
|
+
document.on('click', '.messages a.close', function(event, element) {
|
294
|
+
ActiveScaffold.hide(element.up('.message'));
|
295
|
+
event.stop();
|
296
|
+
});
|
290
297
|
});
|
291
298
|
|
292
299
|
|
@@ -331,13 +338,16 @@ var ActiveScaffold = {
|
|
331
338
|
},
|
332
339
|
reload_if_empty: function(tbody, url) {
|
333
340
|
if (this.records_for(tbody).length == 0) {
|
334
|
-
|
335
|
-
method: 'get',
|
336
|
-
asynchronous: true,
|
337
|
-
evalScripts: true
|
338
|
-
});
|
341
|
+
this.reload(url);
|
339
342
|
}
|
340
343
|
},
|
344
|
+
reload: function(url) {
|
345
|
+
new Ajax.Request(url, {
|
346
|
+
method: 'get',
|
347
|
+
asynchronous: true,
|
348
|
+
evalScripts: true
|
349
|
+
});
|
350
|
+
},
|
341
351
|
removeSortClasses: function(scaffold) {
|
342
352
|
scaffold = $(scaffold)
|
343
353
|
scaffold.select('td.sorted').each(function(element) {
|
@@ -385,6 +395,11 @@ var ActiveScaffold = {
|
|
385
395
|
$(element).remove();
|
386
396
|
},
|
387
397
|
|
398
|
+
update_inplace_edit: function(element, value, empty) {
|
399
|
+
this.replace_html(element, value);
|
400
|
+
if (empty) $(element).up('td').addClassName('empty');
|
401
|
+
},
|
402
|
+
|
388
403
|
hide: function(element) {
|
389
404
|
$(element).hide();
|
390
405
|
},
|
@@ -482,10 +497,19 @@ var ActiveScaffold = {
|
|
482
497
|
},
|
483
498
|
|
484
499
|
find_action_link: function(element) {
|
485
|
-
|
500
|
+
element = $(element);
|
501
|
+
return ActiveScaffold.ActionLink.get(element.match('.actions a') ? element : element.up('.as_adapter'));
|
486
502
|
},
|
487
503
|
|
488
|
-
scroll_to: function(element) {
|
504
|
+
scroll_to: function(element, checkInViewport) {
|
505
|
+
if (typeof checkInViewport == 'undefined') checkInViewport = true;
|
506
|
+
var form_offset = $(element).viewportOffset().top;
|
507
|
+
if (checkInViewport) {
|
508
|
+
var docViewTop = document.viewport.getScrollOffsets().top,
|
509
|
+
docViewBottom = docViewTop + document.viewport.getHeight();
|
510
|
+
// If it's in viewport , don't scroll;
|
511
|
+
if (form_offset + $(element).getHeight() <= docViewBottom && form_offset >= docViewTop) return;
|
512
|
+
}
|
489
513
|
$(element).scrollTo();
|
490
514
|
},
|
491
515
|
|
@@ -795,7 +819,7 @@ ActiveScaffold.ActionLink.Abstract = Class.create({
|
|
795
819
|
this.enable();
|
796
820
|
this.adapter.remove();
|
797
821
|
if (this.hide_target) this.target.show();
|
798
|
-
if (ActiveScaffold.config.scroll_on_close) ActiveScaffold.scroll_to(this.target);
|
822
|
+
if (ActiveScaffold.config.scroll_on_close) ActiveScaffold.scroll_to(this.target, ActiveScaffold.config.scroll_on_close == 'checkInViewport');
|
799
823
|
},
|
800
824
|
|
801
825
|
get_new_adapter_id: function() {
|
@@ -887,10 +911,10 @@ ActiveScaffold.ActionLink.Record = Class.create(ActiveScaffold.ActionLink.Abstra
|
|
887
911
|
},
|
888
912
|
|
889
913
|
close: function($super, refreshed_content) {
|
914
|
+
$super();
|
890
915
|
if (refreshed_content) {
|
891
916
|
ActiveScaffold.update_row(this.target, refreshed_content);
|
892
917
|
}
|
893
|
-
$super();
|
894
918
|
},
|
895
919
|
|
896
920
|
enable: function() {
|
@@ -203,6 +203,12 @@ padding: 0px;
|
|
203
203
|
.active-scaffold tbody.records td.empty {
|
204
204
|
text-align: center;
|
205
205
|
}
|
206
|
+
.active-scaffold tbody.records td.in_place_editor_field .handle {
|
207
|
+
display:none;
|
208
|
+
}
|
209
|
+
.active-scaffold tbody.records td.in_place_editor_field.empty .handle {
|
210
|
+
display:inline;
|
211
|
+
}
|
206
212
|
|
207
213
|
.active-scaffold td.numeric,
|
208
214
|
.active-scaffold-calculations td {
|
@@ -433,6 +439,7 @@ border: none;
|
|
433
439
|
.active-scaffold .empty-message, .active-scaffold .filtered-message {
|
434
440
|
padding: 4px;
|
435
441
|
text-align: center;
|
442
|
+
position: relative;
|
436
443
|
}
|
437
444
|
|
438
445
|
.active-scaffold .message {
|
@@ -444,7 +451,15 @@ margin: 2px 7px;
|
|
444
451
|
line-height: 12px;
|
445
452
|
}
|
446
453
|
|
447
|
-
.active-scaffold .message
|
454
|
+
.active-scaffold .filtered-message .reset {
|
455
|
+
position: absolute;
|
456
|
+
display: inline;
|
457
|
+
right: 10px;
|
458
|
+
top: 4px;
|
459
|
+
padding: 0;
|
460
|
+
}
|
461
|
+
|
462
|
+
.active-scaffold .message a.close {
|
448
463
|
position: absolute;
|
449
464
|
right: 10px;
|
450
465
|
top: 4px;
|
@@ -594,6 +609,14 @@ padding: 2px;
|
|
594
609
|
margin-left: 5px;
|
595
610
|
list-style: none;
|
596
611
|
}
|
612
|
+
.active-scaffold ol:after {
|
613
|
+
content: '.';
|
614
|
+
visibility: hidden;
|
615
|
+
line-height: 0;
|
616
|
+
height: 0;
|
617
|
+
display: block;
|
618
|
+
clear: both;
|
619
|
+
}
|
597
620
|
|
598
621
|
.active-scaffold p.form-footer {
|
599
622
|
clear: both;
|
@@ -1,4 +1,6 @@
|
|
1
|
-
<%
|
1
|
+
<% scope ||= nil
|
2
|
+
footer_extension ||= nil
|
3
|
+
url_options ||= params_for(:action => form_action)
|
2
4
|
xhr = request.xhr? if xhr.nil?
|
3
5
|
if active_scaffold_config.actions.include? form_action
|
4
6
|
multipart ||= active_scaffold_config.send(form_action).multipart?
|
@@ -7,6 +9,9 @@
|
|
7
9
|
multipart ||= false
|
8
10
|
columns ||= nil
|
9
11
|
end
|
12
|
+
method ||= :post
|
13
|
+
cancel_link = true if cancel_link.nil?
|
14
|
+
submit_text ||= form_action
|
10
15
|
body_partial ||= 'form' %>
|
11
16
|
<%=
|
12
17
|
options = {:onsubmit => onsubmit,
|
@@ -29,22 +34,16 @@ end
|
|
29
34
|
<h4><%= headline -%></h4>
|
30
35
|
|
31
36
|
<div id="<%= element_messages_id(:action => form_action) %>" class="messages-container">
|
32
|
-
<% if request.xhr? -%>
|
33
|
-
<% records = @error_records || Array(@record)
|
34
|
-
records.each do |record| %>
|
35
|
-
<%= active_scaffold_error_messages_for record, :object_name => "#{record.class.model_name.human.downcase}#{record.new_record? ? '' : ": #{record.to_label}"}" %>
|
36
|
-
<% end %>
|
37
|
-
<% else -%>
|
38
37
|
<%= render :partial => 'form_messages' %>
|
39
|
-
<% end -%>
|
40
38
|
</div>
|
41
39
|
|
42
|
-
<%= render :partial => body_partial, :locals => { :columns => columns, :form_action => form_action } %>
|
40
|
+
<%= render :partial => body_partial, :locals => { :columns => columns, :form_action => form_action, :scope => scope } %>
|
43
41
|
|
44
42
|
<p class="form-footer">
|
45
|
-
<%= submit_tag as_(
|
43
|
+
<%= submit_tag as_(submit_text), :class => "submit" %>
|
46
44
|
<%= link_to(as_(:cancel), main_path_to_return, cancel_options) if cancel_link %>
|
47
45
|
<%= loading_indicator_tag(:action => form_action, :id => params[:id]) %>
|
46
|
+
<%= render :partial => footer_extension, :locals => { :form_action => form_action } if footer_extension %>
|
48
47
|
</p>
|
49
48
|
|
50
49
|
</form>
|
@@ -1,5 +1,8 @@
|
|
1
|
-
<%
|
2
|
-
|
1
|
+
<%
|
2
|
+
scope ||= nil
|
3
|
+
subsection_id ||= nil
|
4
|
+
show_unauthorized_columns = active_scaffold_config.send(form_action).show_unauthorized_columns
|
5
|
+
%>
|
3
6
|
<ol class="form" <%= "id=#{subsection_id}" unless subsection_id.nil? %> <%= "style=\"display: none;\"".html_safe if columns.collapsed %>>
|
4
7
|
<% columns.each :for => @record, :crud_type => (:read if show_unauthorized_columns) do |column| %>
|
5
8
|
<% authorized = show_unauthorized_columns ? @record.authorized_for?(:crud_type => form_action, :column => column.name) : true %>
|
@@ -8,18 +11,16 @@
|
|
8
11
|
<% subsection_id = sub_section_id(:sub_section => column.label) %>
|
9
12
|
<li class="sub-section <%= column.css_class %>">
|
10
13
|
<h5><%= column.label %></h5>
|
11
|
-
<%= render :partial => 'form', :locals => { :columns => column, :subsection_id => subsection_id, :form_action => form_action } %>
|
14
|
+
<%= render :partial => 'form', :locals => { :columns => column, :subsection_id => subsection_id, :form_action => form_action, :scope => scope } %>
|
12
15
|
<%= link_to_visibility_toggle(subsection_id, {:default_visible => !column.collapsed}) -%>
|
13
16
|
</li>
|
14
|
-
<% elsif column.readonly_association?
|
15
|
-
next %>
|
16
17
|
<% elsif renders_as == :subform and !override_form_field?(column) and authorized -%>
|
17
18
|
<li class="sub-form <%= active_scaffold_config_for(column.association.klass).subform.layout %>-sub-form <%= column.css_class unless column.css_class.nil? || column.css_class.is_a?(Proc) %> <%=column.name%>-sub-form" id="<%= sub_form_id(:association => column.name) %>">
|
18
|
-
<%=raw render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column } -%>
|
19
|
+
<%=raw render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column, :scope => scope } -%>
|
19
20
|
</li>
|
20
21
|
<% else -%>
|
21
22
|
<li class="form-element <%= 'required' if column.required? %> <%= column.css_class unless column.css_class.nil? || column.css_class.is_a?(Proc) %>">
|
22
|
-
<%=raw render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column, :only_value => !authorized } -%>
|
23
|
+
<%=raw render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column, :only_value => !authorized, :scope => scope } -%>
|
23
24
|
</li>
|
24
25
|
<% end -%>
|
25
26
|
<% end -%>
|