active_scaffold 3.0.5 → 3.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/.document +5 -0
  2. data/Gemfile +11 -2
  3. data/Gemfile.lock +20 -0
  4. data/Rakefile +33 -4
  5. data/active_scaffold.gemspec +378 -17
  6. data/frontends/default/images/config.png +0 -0
  7. data/frontends/default/images/gears.png +0 -0
  8. data/frontends/default/javascripts/jquery/active_scaffold.js +34 -33
  9. data/frontends/default/javascripts/jquery/jquery.editinplace.js +21 -4
  10. data/frontends/default/javascripts/prototype/active_scaffold.js +43 -38
  11. data/frontends/default/stylesheets/stylesheet.css +110 -35
  12. data/frontends/default/views/_action_group.html.erb +20 -0
  13. data/frontends/default/views/_base_form.html.erb +7 -3
  14. data/frontends/default/views/_create_form.html.erb +5 -3
  15. data/frontends/default/views/_create_form_on_list.html.erb +2 -1
  16. data/frontends/default/views/_field_search.html.erb +2 -2
  17. data/frontends/default/views/_form.html.erb +2 -2
  18. data/frontends/default/views/_form_messages.html.erb +1 -1
  19. data/frontends/default/views/_horizontal_subform.html.erb +1 -1
  20. data/frontends/default/views/_list_actions.html.erb +6 -14
  21. data/frontends/default/views/_list_header.html.erb +4 -6
  22. data/frontends/default/views/_list_with_header.html.erb +2 -2
  23. data/frontends/default/views/_messages.html.erb +2 -2
  24. data/frontends/default/views/_search.html.erb +2 -2
  25. data/frontends/default/views/_show.html.erb +1 -1
  26. data/frontends/default/views/_update_form.html.erb +2 -1
  27. data/frontends/default/views/_vertical_subform.html.erb +1 -1
  28. data/frontends/default/views/action_confirmation.html.erb +13 -0
  29. data/frontends/default/views/add_existing.js.rjs +1 -1
  30. data/frontends/default/views/destroy.js.rjs +21 -3
  31. data/frontends/default/views/on_action_update.js.rjs +1 -1
  32. data/frontends/default/views/on_create.js.rjs +30 -13
  33. data/frontends/default/views/on_update.js.rjs +19 -6
  34. data/init.rb +6 -0
  35. data/lib/active_scaffold/actions/core.rb +32 -12
  36. data/lib/active_scaffold/actions/create.rb +4 -11
  37. data/lib/active_scaffold/actions/delete.rb +16 -13
  38. data/lib/active_scaffold/actions/list.rb +58 -2
  39. data/lib/active_scaffold/actions/mark.rb +1 -1
  40. data/lib/active_scaffold/actions/nested.rb +24 -15
  41. data/lib/active_scaffold/actions/show.rb +10 -3
  42. data/lib/active_scaffold/actions/update.rb +10 -3
  43. data/lib/{active_record_permissions.rb → active_scaffold/active_record_permissions.rb} +0 -0
  44. data/lib/active_scaffold/bridges/ancestry/lib/ancestry_bridge.rb +9 -8
  45. data/lib/active_scaffold/bridges/bridge.rb +1 -1
  46. data/lib/active_scaffold/bridges/calendar_date_select/lib/as_cds_bridge.rb +8 -4
  47. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +1 -1
  48. data/lib/active_scaffold/bridges/paperclip/bridge.rb +1 -1
  49. data/lib/active_scaffold/bridges/paperclip/lib/list_ui.rb +1 -1
  50. data/lib/active_scaffold/config/base.rb +8 -0
  51. data/lib/active_scaffold/config/core.rb +2 -15
  52. data/lib/active_scaffold/config/create.rb +8 -0
  53. data/lib/active_scaffold/config/delete.rb +10 -1
  54. data/lib/active_scaffold/config/field_search.rb +1 -0
  55. data/lib/active_scaffold/config/form.rb +2 -1
  56. data/lib/active_scaffold/config/nested.rb +3 -2
  57. data/lib/active_scaffold/config/search.rb +1 -0
  58. data/lib/active_scaffold/config/show.rb +1 -0
  59. data/lib/active_scaffold/config/update.rb +8 -0
  60. data/lib/active_scaffold/constraints.rb +9 -4
  61. data/lib/active_scaffold/data_structures/action_columns.rb +1 -1
  62. data/lib/active_scaffold/data_structures/action_link.rb +10 -1
  63. data/lib/active_scaffold/data_structures/action_links.rb +62 -22
  64. data/lib/active_scaffold/data_structures/column.rb +17 -13
  65. data/lib/active_scaffold/data_structures/nested_info.rb +21 -6
  66. data/lib/active_scaffold/finder.rb +2 -1
  67. data/lib/active_scaffold/helpers/association_helpers.rb +2 -2
  68. data/lib/active_scaffold/helpers/controller_helpers.rb +57 -10
  69. data/lib/active_scaffold/helpers/form_column_helpers.rb +12 -8
  70. data/lib/active_scaffold/helpers/id_helpers.rb +5 -9
  71. data/lib/active_scaffold/helpers/list_column_helpers.rb +26 -28
  72. data/lib/active_scaffold/helpers/search_column_helpers.rb +8 -3
  73. data/lib/active_scaffold/helpers/view_helpers.rb +60 -19
  74. data/lib/active_scaffold/locale/de.rb +13 -6
  75. data/lib/active_scaffold/locale/en.rb +2 -1
  76. data/lib/active_scaffold/locale/es.yml +3 -0
  77. data/lib/active_scaffold/locale/fr.rb +5 -2
  78. data/lib/active_scaffold/locale/ru.yml +77 -20
  79. data/lib/active_scaffold/marked_model.rb +5 -5
  80. data/lib/{paginator.rb → active_scaffold/paginator.rb} +0 -0
  81. data/lib/{responds_to_parent.rb → active_scaffold/responds_to_parent.rb} +0 -0
  82. data/lib/active_scaffold/version.rb +9 -0
  83. data/lib/active_scaffold.rb +60 -84
  84. data/lib/active_scaffold_assets.rb +45 -0
  85. data/lib/active_scaffold_env.rb +14 -0
  86. data/lib/active_scaffold_vho.rb +2 -0
  87. data/lib/extensions/active_association_reflection.rb +13 -0
  88. data/lib/extensions/paginator_extensions.rb +1 -1
  89. data/lib/extensions/routing_mapper.rb +1 -1
  90. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +12 -4
  91. metadata +85 -68
  92. data/lib/dhtml_confirm.rb +0 -54
@@ -455,6 +455,7 @@ $.extend(InlineEditor.prototype, {
455
455
  return;
456
456
 
457
457
  var editor = this.dom.find(':input');
458
+
458
459
  var enteredText = editor.val();
459
460
  enteredText = this.triggerDelegateCall('willCloseEditInPlace', enteredText);
460
461
 
@@ -468,8 +469,16 @@ $.extend(InlineEditor.prototype, {
468
469
  handleSaveEditor: function(anEvent) {
469
470
  if (false === this.triggerDelegateCall('shouldCloseEditInPlace', true, anEvent))
470
471
  return;
471
-
472
- var enteredText = this.dom.find(':input').val();
472
+
473
+ var editor = this.dom.find(':input:not(:button)');
474
+ var enteredText = '';
475
+ if (editor.length > 1) {
476
+ enteredText = jQuery.map(editor.not('input:checkbox:not(:checked)'), function(item, index) {
477
+ return $(item).val();
478
+ });
479
+ } else {
480
+ enteredText = editor.val();
481
+ }
473
482
  enteredText = this.triggerDelegateCall('willCloseEditInPlace', enteredText);
474
483
 
475
484
  if (this.isDisabledDefaultSelectChoice()
@@ -545,8 +554,16 @@ $.extend(InlineEditor.prototype, {
545
554
  },
546
555
 
547
556
  handleSubmitToServer: function(enteredText) {
548
- var data = this.settings.update_value + '=' + encodeURIComponent(enteredText)
549
- + '&' + this.settings.element_id + '=' + this.dom.attr("id")
557
+ var data = '';
558
+ if (typeof(enteredText) === 'string') {
559
+ data += this.settings.update_value + '=' + encodeURIComponent(enteredText) + '&';
560
+ } else {
561
+ for(var i = 0;i < enteredText.length; i++) {
562
+ data += this.settings.update_value + '[]=' + encodeURIComponent(enteredText[i]) + '&';
563
+ }
564
+ }
565
+
566
+ data += this.settings.element_id + '=' + this.dom.attr("id")
550
567
  + ((this.settings.params) ? '&' + this.settings.params : '')
551
568
  + '&' + this.settings.original_html + '=' + encodeURIComponent(this.originalValue) /* DEPRECATED in 2.2.0 */
552
569
  + '&' + this.settings.original_value + '=' + encodeURIComponent(this.originalValue);
@@ -45,7 +45,7 @@ document.observe("dom:loaded", function() {
45
45
  document.on('submit', 'form.as_form.as_remote_upload', function(event) {
46
46
  var as_form = event.findElement('form');
47
47
  if (as_form && as_form.readAttribute('data-loading') == 'true') {
48
- setTimeout("ActiveScaffold.disable_form('" + as_form.id + "')", 10);
48
+ setTimeout("ActiveScaffold.disable_form('" + as_form.readAttribute('id') + "')", 10);
49
49
  }
50
50
  return true;
51
51
  });
@@ -177,10 +177,17 @@ document.observe("dom:loaded", function() {
177
177
  if (record_id) options.url = options.url.sub('__id__', record_id);
178
178
 
179
179
  if (csrf_param) options['params'] = csrf_param.readAttribute('content') + '=' + csrf_token.readAttribute('content');
180
+
181
+ if (span.up('div.active-scaffold').readAttribute('data-eid')) {
182
+ if (options['params'].length > 0) {
183
+ options['params'] += ";";
184
+ }
185
+ options['params'] += ("eid=" + span.up('div.active-scaffold').readAttribute('data-eid'));
186
+ }
180
187
 
181
188
  if (mode === 'clone') {
182
189
  options.nodeIdSuffix = record_id;
183
- options.inplacePatternSelector = '#' + column_heading.id + ' .as_inplace_pattern';
190
+ options.inplacePatternSelector = '#' + column_heading.readAttribute('id') + ' .as_inplace_pattern';
184
191
  options['onFormCustomization'] = new Function('element', 'form', 'element.clonePatternField();');
185
192
  }
186
193
 
@@ -251,14 +258,14 @@ document.observe("dom:loaded", function() {
251
258
  });
252
259
  document.on('change', 'select.as_search_range_option', function(event) {
253
260
  var element = event.findElement();
254
- Element[element.value == 'BETWEEN' ? 'show' : 'hide'](element.id.sub('_opt', '_between'));
261
+ Element[element.value == 'BETWEEN' ? 'show' : 'hide'](element.readAttribute('id').sub('_opt', '_between'));
255
262
  return true;
256
263
  });
257
264
  document.on('change', 'select.as_search_date_time_option', function(event) {
258
265
  var element = event.findElement();
259
- Element[!(element.value == 'PAST' || element.value == 'FUTURE' || element.value == 'RANGE') ? 'show' : 'hide'](element.id.sub('_opt', '_numeric'));
260
- Element[(element.value == 'PAST' || element.value == 'FUTURE') ? 'show' : 'hide'](element.id.sub('_opt', '_trend'));
261
- Element[element.value == 'RANGE' ? 'show' : 'hide'](element.id.sub('_opt', '_range'));
266
+ Element[!(element.value == 'PAST' || element.value == 'FUTURE' || element.value == 'RANGE') ? 'show' : 'hide'](element.readAttribute('id').sub('_opt', '_numeric'));
267
+ Element[(element.value == 'PAST' || element.value == 'FUTURE') ? 'show' : 'hide'](element.readAttribute('id').sub('_opt', '_trend'));
268
+ Element[element.value == 'RANGE' ? 'show' : 'hide'](element.readAttribute('id').sub('_opt', '_range'));
262
269
  return true;
263
270
  });
264
271
  document.on('change', 'select.as_update_date_operator', function(event) {
@@ -268,6 +275,11 @@ document.observe("dom:loaded", function() {
268
275
  Element[element.value == 'REPLACE' ? 'hide' : 'show'](element.next('span'));
269
276
  return true;
270
277
  });
278
+ document.on("click", "a[data-popup]", function(event, element) {
279
+ if (event.stopped) return;
280
+ window.open($(element).href);
281
+ event.stop();
282
+ });
271
283
  });
272
284
 
273
285
 
@@ -352,7 +364,7 @@ var ActiveScaffold = {
352
364
  replace: function(element, html) {
353
365
  element = $(element)
354
366
  Element.replace(element, html);
355
- element = $(element.id);
367
+ element = $(element.readAttribute('id'));
356
368
  return element;
357
369
  },
358
370
 
@@ -380,14 +392,14 @@ var ActiveScaffold = {
380
392
 
381
393
  disable_form: function(as_form) {
382
394
  as_form = $(as_form)
383
- var loading_indicator = $(as_form.id.sub('-form', '-loading-indicator'));
395
+ var loading_indicator = $(as_form.readAttribute('id').sub('-form', '-loading-indicator'));
384
396
  if (loading_indicator) loading_indicator.style.visibility = 'visible';
385
397
  as_form.disable();
386
398
  },
387
399
 
388
400
  enable_form: function(as_form) {
389
401
  as_form = $(as_form)
390
- var loading_indicator = $(as_form.id.sub('-form', '-loading-indicator'));
402
+ var loading_indicator = $(as_form.readAttribute('id').sub('-form', '-loading-indicator'));
391
403
  if (loading_indicator) loading_indicator.style.visibility = 'hidden';
392
404
  as_form.enable();
393
405
  },
@@ -396,8 +408,9 @@ var ActiveScaffold = {
396
408
  Form.focusFirstElement(form_element);
397
409
  },
398
410
 
399
- create_record_row: function(tbody, html, options) {
400
- tbody = $(tbody);
411
+ create_record_row: function(active_scaffold_id, html, options) {
412
+ tbody = $(active_scaffold_id).down('tbody.records');
413
+
401
414
  var new_row = null;
402
415
 
403
416
  if (options.insert_at == 'top') {
@@ -432,6 +445,7 @@ var ActiveScaffold = {
432
445
  }
433
446
  }
434
447
  row.remove();
448
+ tbody = $(tbody);
435
449
  this.stripe(tbody);
436
450
  this.decrement_record_count(tbody.up('div.active-scaffold'));
437
451
  this.reload_if_empty(tbody, page_reload_url);
@@ -485,7 +499,7 @@ var ActiveScaffold = {
485
499
  options['callback'] = new Function('form', 'return Form.serialize(form) + ' + "'&" + options['params'] + "';");
486
500
  }
487
501
  span.removeClassName('hover');
488
- span.inplace_edit = new ActiveScaffold.InPlaceEditor(span.id, options.url, options)
502
+ span.inplace_edit = new ActiveScaffold.InPlaceEditor(span.readAttribute('id'), options.url, options)
489
503
  span.inplace_edit.enterEditMode();
490
504
  },
491
505
 
@@ -499,6 +513,7 @@ var ActiveScaffold = {
499
513
  var element = event.element();
500
514
  toggable.toggle();
501
515
  element.innerHTML = (toggable.style.display == 'none') ? options.show_label : options.hide_label;
516
+ return false;
502
517
  });
503
518
  },
504
519
 
@@ -509,8 +524,9 @@ var ActiveScaffold = {
509
524
  element.insert(content);
510
525
  }
511
526
  } else {
512
- if (current = $$('#' + element.id + ' tr.association-record')[0]) {
513
- this.replace(current, content);
527
+ var current = $$('#' + element.readAttribute('id') + ' tr.association-record');
528
+ if (current[0]) {
529
+ this.replace(current[0], content);
514
530
  } else {
515
531
  element.insert({top: content});
516
532
  }
@@ -643,7 +659,11 @@ ActiveScaffold.ActionLink = {
643
659
  get: function(element) {
644
660
  var element = $(element);
645
661
  if (typeof(element.retrieve('action_link')) === 'undefined' && !element.hasClassName('as_adapter')) {
646
- var parent = element.up();
662
+ var parent = element.up('.actions');
663
+ if (typeof(parent) === 'undefined') {
664
+ // maybe an column action_link
665
+ parent = element.up();
666
+ }
647
667
  if (parent && parent.nodeName.toUpperCase() == 'TD') {
648
668
  // record action
649
669
  parent = parent.up('tr.record')
@@ -662,25 +682,11 @@ ActiveScaffold.ActionLink.Abstract = Class.create({
662
682
  initialize: function(a, target, loading_indicator) {
663
683
  this.tag = $(a);
664
684
  this.url = this.tag.href;
665
- this.method = 'get';
666
-
667
- if(this.url.match('_method=delete')){
668
- this.method = 'delete';
669
- // action delete is special case cause in ajax world it will be destroy
670
- } else if(this.url.match('/delete')){
671
- this.url = this.url.replace('/delete', '');
672
- this.tag.href = this.url;
673
- this.method = 'delete';
674
- } else if(this.url.match('_method=post')){
675
- this.method = 'post';
676
- } else if(this.url.match('_method=put')){
677
- this.method = 'put';
678
- }
679
- if (this.method != 'get') this.tag.writeAttribute('data-method', this.method);
685
+ this.method = this.tag.readAttribute('data-method') || 'get';
680
686
  this.target = target;
681
687
  this.loading_indicator = loading_indicator;
682
688
  this.hide_target = false;
683
- this.position = this.tag.getAttribute('data-position');
689
+ this.position = this.tag.readAttribute('data-position');
684
690
 
685
691
  this.tag.store('action_link', this);
686
692
  },
@@ -723,7 +729,11 @@ ActiveScaffold.ActionLink.Abstract = Class.create({
723
729
  },
724
730
 
725
731
  scaffold_id: function() {
726
- return this.tag.up('div.active-scaffold').id;
732
+ return this.tag.up('div.active-scaffold').readAttribute('id');
733
+ },
734
+
735
+ scaffold: function() {
736
+ return this.tag.up('div.active-scaffold');
727
737
  },
728
738
 
729
739
  update_flash_messages: function(messages) {
@@ -744,13 +754,8 @@ ActiveScaffold.ActionLink.Abstract = Class.create({
744
754
  ActiveScaffold.Actions.Record = Class.create(ActiveScaffold.Actions.Abstract, {
745
755
  instantiate_link: function(link) {
746
756
  var l = new ActiveScaffold.ActionLink.Record(link, this.target, this.loading_indicator);
747
- if (!this.target.readAttribute('data-refresh').blank()) l.refresh_url = this.target.readAttribute('data-refresh');
757
+ if (this.target.hasAttribute('data-refresh') && !this.target.readAttribute('data-refresh').blank()) l.refresh_url = this.target.readAttribute('data-refresh');
748
758
 
749
- if (link.hasClassName('delete')) {
750
- l.url = l.url.replace(/\/delete(\?.*)?$/, '$1');
751
- l.url = l.url.replace(/\/delete\/(.*)/, '/destroy/$1');
752
- l.tag.href = l.url;
753
- }
754
759
  if (l.position) {
755
760
  l.url = l.url.append_params({adapter: '_list_inline_adapter'});
756
761
  l.tag.href = l.url;
@@ -35,7 +35,7 @@ text-decoration: none;
35
35
  color: #999;
36
36
  }
37
37
 
38
- .active-scaffold a:hover, .active-scaffold span.hover {
38
+ .active-scaffold a:hover, .active-scaffold div.hover {
39
39
  background-color: #ff8;
40
40
  }
41
41
 
@@ -86,7 +86,8 @@ color: #fff;
86
86
  padding: 2px 5px 4px 5px;
87
87
  }
88
88
 
89
- .active-scaffold-header div.actions a {
89
+ .active-scaffold-header div.actions a,
90
+ .active-scaffold-header div.actions {
90
91
  float: right;
91
92
  font: bold 14px arial;
92
93
  letter-spacing: -1px;
@@ -98,7 +99,25 @@ background-position: 1px 50%;
98
99
  background-repeat: no-repeat;
99
100
  }
100
101
 
101
- .view .active-scaffold-header div.actions a {
102
+ .active-scaffold-header div.actions div.action_group {
103
+ display: inline;
104
+ float: right;
105
+ }
106
+
107
+ .active-scaffold-header div.actions div.action_group li a,
108
+ .active-scaffold-header div.actions div.action_group li div {
109
+ float: none;
110
+ margin: 0;
111
+ }
112
+
113
+ .active-scaffold-header div.actions .action_group ul {
114
+ line-height: 130%;
115
+ top: 14px;
116
+ }
117
+
118
+ .view .active-scaffold-header div.actions a,
119
+ .view .active-scaffold-header div.actions div,
120
+ .view .active-scaffold-header div.actions div.action_group {
102
121
  float: left;
103
122
  }
104
123
 
@@ -118,12 +137,23 @@ opacity: 0.5;
118
137
 
119
138
  .active-scaffold-header div.actions a.new,
120
139
  .active-scaffold-header div.actions a.new_existing,
121
- .active-scaffold-header div.actions a.show_search {
122
- padding-left: 19px;
140
+ .active-scaffold-header div.actions a.show_search,
141
+ .active-scaffold-header div.actions a.show_config_list,
142
+ .active-scaffold-header div.actions div.action_group div {
143
+ margin:0;
144
+ padding: 1px 5px 1px 20px;
123
145
  background-position: 1px 50%;
124
146
  background-repeat: no-repeat;
125
147
  }
126
148
 
149
+ .active-scaffold-header div.actions div.action_group div {
150
+ background-image: url(../../../images/active_scaffold/default/gears.png); /* default icon for actions or override with css */
151
+ }
152
+
153
+ .active-scaffold-header div.actions a.show_config_list {
154
+ background-image: url(../../../images/active_scaffold/default/config.png);
155
+ }
156
+
127
157
  .active-scaffold-header div.actions a.new,
128
158
  .active-scaffold-header div.actions a.new_existing {
129
159
  background-image: url(../../../images/active_scaffold/default/add.gif);
@@ -166,7 +196,7 @@ background-color: #555;
166
196
 
167
197
  .active-scaffold th a, .active-scaffold th a:visited {
168
198
  color: #fff;
169
- padding: 2px 15px 2px 5px;
199
+ padding: 2px 2px 2px 5px;
170
200
  }
171
201
 
172
202
  .active-scaffold th p {
@@ -183,6 +213,10 @@ color: #ff8;
183
213
  background-color: #333;
184
214
  }
185
215
 
216
+ .active-scaffold th.sorted a {
217
+ padding-right: 18px;
218
+ }
219
+
186
220
  .active-scaffold th.asc a,
187
221
  .active-scaffold th.asc a:hover {
188
222
  background: #333 url(../../../images/active_scaffold/default/arrow_up.gif) right 50% no-repeat;
@@ -198,6 +232,10 @@ background: #333 url(../../../images/active_scaffold/default/arrow_down.gif) rig
198
232
  background: #333 url(../../../images/active_scaffold/default/indicator-small.gif) right 50% no-repeat;
199
233
  }
200
234
 
235
+ .active-scaffold th .mark_heading {
236
+ margin-left: 5px;
237
+ }
238
+
201
239
  /* Table :: Record Rows
202
240
  ============================= */
203
241
 
@@ -265,7 +303,7 @@ padding: 0 2px;
265
303
  }
266
304
 
267
305
  .active-scaffold tr.record td.actions a,
268
- .active-scaffold tr.record td.actions span {
306
+ .active-scaffold tr.record td.actions div {
269
307
  font: bold 11px verdana, sans-serif;
270
308
  letter-spacing: -1px;
271
309
  padding: 2px;
@@ -274,42 +312,79 @@ line-height: 16px;
274
312
  white-space: nowrap;
275
313
  }
276
314
 
277
- .active-scaffold tr.record td.actions td.action_list {
278
- position:relative;
279
- text-align: left;
280
- color: #0066CC;
315
+ .active-scaffold tr.record td.actions a.disabled {
316
+ color: #666;
317
+ opacity: 0.5;
318
+ }
319
+
320
+ .active-scaffold .actions .action_group div:hover {
321
+ background-color: #ff8;
281
322
  }
282
323
 
283
- .active-scaffold tr.record td.actions .action_list ul {
284
- border:medium none;
285
- list-style-type:none;
286
- margin:0;
287
- padding:0;
288
- position:absolute;
289
- line-height:200%;
324
+ .active-scaffold .actions .action_group {
325
+ position: relative;
326
+ text-align: left;
327
+ color: #0066CC;
328
+ }
329
+
330
+ .active-scaffold .actions .action_group ul {
331
+ border: 2px solid #005CB8;
332
+ list-style-type: none;
333
+ margin: 0;
334
+ padding: 0;
335
+ position: absolute;
336
+ line-height: 200%;
337
+ display: none;
338
+ width: 150px;
339
+ right: 0px;
340
+ }
341
+
342
+ .active-scaffold .actions .action_group ul ul {
290
343
  display: none;
291
- width:100%;
292
- }
293
-
294
- .active-scaffold tr.record td.actions .action_list ul li {
295
- background:none repeat scroll 0 0 #FFF;
296
- border-bottom:1px solid #AFD0F5;
297
- border-left:1px solid #AFD0F5;
298
- border-right:1px solid #AFD0F5;
299
- color:#000000;
300
- display:block;
301
- padding-bottom:5px;
302
- position:relative;
303
- width:160px;
344
+ position: absolute;
345
+ top: 0;
346
+ right: 150px;
347
+ }
348
+
349
+ .active-scaffold .actions .action_group ul li {
350
+ background: none repeat scroll 0 0 #EEE;
351
+ border-top: 1px dashed #222;
352
+ display: block;
353
+ position: relative;
354
+ width: auto;
304
355
  z-index: 2;
305
356
  }
306
357
 
307
- .active-scaffold tr.record td.actions td.action_list:hover ul {
308
- display:block;
358
+ .active-scaffold .actions .action_group ul li div {
359
+ margin: 0;
360
+ padding: 5px 5px 5px 25px;
361
+ background-position: 5px 50%;
362
+ background-repeat: no-repeat;
363
+ }
364
+
365
+ .active-scaffold .actions .action_group ul li a {
366
+ display: block;
367
+ color: #333;
368
+ margin: 0;
369
+ padding: 5px 5px 5px 25px;
370
+ background-position: 5px 50%;
371
+ background-repeat: no-repeat;
309
372
  }
310
373
 
374
+ .active-scaffold .actions .action_group ul li.top {
375
+ border-top: 0px solid #005CB8;
376
+ }
311
377
 
378
+ .active-scaffold .actions .action_group:hover ul ul,
379
+ .active-scaffold .actions .action_group:hover ul ul ul {
380
+ display: none;
381
+ }
312
382
 
383
+ .active-scaffold .actions .action_group:hover ul,
384
+ .active-scaffold .actions .action_group ul li:hover > ul,
385
+ .active-scaffold .actions .action_group ul ul li:hover ul {
386
+ display: block;
387
+ }
313
388
 
314
389
  /* Table :: Inline Adapter
315
390
  ============================= */
@@ -365,9 +440,9 @@ top: 0px;
365
440
  right: 0px;
366
441
  }
367
442
 
368
- .active-scaffold .active-scaffold .active-scaffold-header div.actions a {
443
+ .active-scaffold .active-scaffold .active-scaffold-header div.actions a,
444
+ .active-scaffold .active-scaffold .active-scaffold-header div.actions div {
369
445
  font: bold 11px verdana, sans-serif;
370
- padding: 0 2px 1px 17px;
371
446
  }
372
447
 
373
448
  .blue-theme .active-scaffold .active-scaffold-header div.actions a,
@@ -0,0 +1,20 @@
1
+ <% record ||= nil
2
+ start_level_0_tag ||= ''
3
+ end_level_0_tag ||= ''%>
4
+ <% action_links.traverse(controller, traverse_options) do |parent, link, options| -%>
5
+ <% if (options[:node] == :finished_traversing) -%>
6
+ <%= "</ul>#{(options[:level] == 0 ? "</div>#{end_level_0_tag}": '</li>')}".html_safe %>
7
+ <% elsif (options[:node] == :start_traversing) -%>
8
+ <% if options[:level] == 0 %>
9
+ <%= "#{start_level_0_tag}<div class=\"action_group\"> #{content_tag(:div, as_(parent.name), :class => (parent.name.to_s).downcase)}<ul>".html_safe %>
10
+ <% else %>
11
+ <%= "<li #{"class=\"top\"" if options[:first_action]}>#{content_tag(:div, as_(parent.name), :class => (parent.name.to_s).downcase)}<ul>".html_safe %>
12
+ <% end %>
13
+ <% else -%>
14
+ <% if options[:level] == 0 %>
15
+ <%= "#{start_level_0_tag}#{h(render_group_action_link(link, url_options, options, record))}#{end_level_0_tag}".html_safe %>
16
+ <% else %>
17
+ <%= content_tag('li', render_group_action_link(link, url_options, options, record), options[:first_action] ? {:class => 'top'}: {}) %>
18
+ <% end %>
19
+ <% end -%>
20
+ <% end -%>
@@ -9,12 +9,16 @@ options = {:onsubmit => onsubmit,
9
9
  :class => "as_form #{form_action.to_s}",
10
10
  :method => method,
11
11
  'data-loading' => true}
12
+ cancel_options = {:class => 'as_cancel', 'data-refresh' => false}
13
+
14
+ cancel_options[:remote] = true if xhr #cancel link does nt have to care about multipart forms
12
15
  if xhr && as_action_config.multipart? # file_uploads
13
16
  form_remote_upload_tag url_options.merge({:iframe => true}), options
14
17
  else
15
18
  options[:remote] = true if xhr && !as_action_config.multipart?
16
19
  form_tag url_options, options
17
- end -%>
20
+ end
21
+ -%>
18
22
 
19
23
  <h4><%= headline -%></h4>
20
24
 
@@ -22,7 +26,7 @@ end -%>
22
26
  <% if request.xhr? -%>
23
27
  <% records = @error_records || Array(@record)
24
28
  records.each do |record| %>
25
- <%= error_messages_for record, :object_name => "#{record.class.model_name.human.downcase}#{record.new_record? ? '' : ": #{record.to_label}"}" %>
29
+ <%= active_scaffold_error_messages_for record, :object_name => "#{record.class.model_name.human.downcase}#{record.new_record? ? '' : ": #{record.to_label}"}" %>
26
30
  <% end %>
27
31
  <% else -%>
28
32
  <%= render :partial => 'form_messages' %>
@@ -33,7 +37,7 @@ end -%>
33
37
 
34
38
  <p class="form-footer">
35
39
  <%= submit_tag as_(form_action), :class => "submit" %>
36
- <%= link_to(as_(:cancel), main_path_to_return, :class => 'as_cancel', :remote => true, 'data-refresh' => false) if cancel_link %>
40
+ <%= link_to(as_(:cancel), main_path_to_return, cancel_options) if cancel_link %>
37
41
  <%= loading_indicator_tag(:action => form_action, :id => params[:id]) %>
38
42
  </p>
39
43
 
@@ -1,6 +1,8 @@
1
+ <% form_action ||= :create
2
+ cancel_link = true if cancel_link.nil? %>
1
3
  <%= render :partial => "base_form", :locals => {:xhr => xhr ||= nil,
2
- :form_action => form_action ||= :create,
4
+ :form_action => form_action,
3
5
  :method => method ||= :post,
4
- :cancel_link => cancel_link ||= true,
5
- :headline => headline ||= active_scaffold_config.create.label(active_scaffold_config.sti_create_links ? @record.class.model_name.human(:count => 1) : nil)} %>
6
+ :cancel_link => cancel_link,
7
+ :headline => headline ||= active_scaffold_config.send(form_action).label(active_scaffold_config.sti_create_links ? @record.class.model_name.human(:count => 1) : nil)} %>
6
8
 
@@ -1,5 +1,6 @@
1
+ <% cancel_link = false if cancel_link.nil? %>
1
2
  <%= render :partial => "base_form", :locals => {:xhr => xhr ||= nil,
2
3
  :form_action => form_action ||= :create,
3
4
  :method => method ||= :post,
4
- :cancel_link => cancel_link ||= false,
5
+ :cancel_link => cancel_link,
5
6
  :headline => headline ||= active_scaffold_config.create.label(active_scaffold_config.sti_create_links ? @record.class.model_name.human(:count => 1) : nil)} %>
@@ -1,6 +1,6 @@
1
1
  <% url_options = params_for(:action => :index, :escape => false, :search => nil) -%>
2
2
  <%=
3
- options = {:id => search_form_id,
3
+ options = {:id => element_form_id(:action => 'search'),
4
4
  :class => "as_form search",
5
5
  :remote => true,
6
6
  :method => :get,
@@ -29,4 +29,4 @@ form_tag url_options, options %>
29
29
  <%= loading_indicator_tag(:action => :search) %>
30
30
  </p>
31
31
  </form>
32
- <%= javascript_tag("ActiveScaffold.focus_first_element_of_form('#{search_form_id}');") %>
32
+ <%= javascript_tag("ActiveScaffold.focus_first_element_of_form('#{element_form_id(:action => 'search')}');") %>
@@ -12,11 +12,11 @@
12
12
  <% elsif column.readonly_association?
13
13
  next %>
14
14
  <% elsif renders_as == :subform and !override_form_field?(column) -%>
15
- <li class="sub-form <%= active_scaffold_config_for(column.association.klass).subform.layout %>-sub-form <%= column.css_class unless column.css_class.nil? %>" id="<%= sub_form_id(:association => column.name) %>">
15
+ <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) %>" id="<%= sub_form_id(:association => column.name) %>">
16
16
  <%= render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column } -%>
17
17
  </li>
18
18
  <% else -%>
19
- <li class="form-element <%= 'required' if column.required? %> <%= column.css_class unless column.css_class.nil? %>">
19
+ <li class="form-element <%= 'required' if column.required? %> <%= column.css_class unless column.css_class.nil? || column.css_class.is_a?(Proc) %>">
20
20
  <%= render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column } -%>
21
21
  </li>
22
22
  <% end -%>
@@ -1,5 +1,5 @@
1
1
  <%= render :partial => 'messages' %>
2
2
 
3
3
  <% unless @record.nil? %>
4
- <%= error_messages_for :record, :object_name => @record.class.model_name.human.downcase %>
4
+ <%= active_scaffold_error_messages_for :record, :object_name => @record.class.model_name.human.downcase %>
5
5
  <% end %>
@@ -8,7 +8,7 @@
8
8
  <% if @record.errors.count -%>
9
9
  <tr class="association-record-errors">
10
10
  <td colspan="<%= active_scaffold_config_for(@record.class).subform.columns.length + 1 %>" id="<%= element_messages_id :action => @record.class.name.underscore, :id => "#{parent_record.id}-#{index}" %>">
11
- <%= error_messages_for :record, :object_name => @record.class.model_name.human.downcase %>
11
+ <%= active_scaffold_error_messages_for :record, :object_name => @record.class.model_name.human.downcase %>
12
12
  </td>
13
13
  </tr>
14
14
  <% end %>
@@ -1,22 +1,14 @@
1
- <% action_links ||= active_scaffold_config.action_links.member %>
2
1
  <td class="actions"><table cellpadding="0" cellspacing="0">
3
2
  <tr>
4
3
  <td class="indicator-container">
5
4
  <%= loading_indicator_tag(:action => :record, :id => record.id) %>
6
5
  </td>
7
- <% level = 0 %>
8
- <% action_links.traverse(controller, {:record => record}) do |parent, link, options| -%>
9
- <% tag = (level == 0 ? 'td' : 'li') %>
10
- <% if (options[:node] == :finished_traversing) -%>
11
- <% level -= 1 %>
12
- <%= "</ul></#{(level == 0 ? 'td' : 'li')}>".html_safe %>
13
- <% elsif (options[:node] == :start_traversing) -%>
14
- <%= "<#{tag} #{"class=\"action_list\"" if tag == 'td'}> #{content_tag('span', parent.name)}<ul>".html_safe %>
15
- <% level += 1 %>
16
- <% else -%>
17
- <%= content_tag(tag, options[:authorized] ? render_action_link(link, url_options, record) : action_link_html(link, nil, {:class => "disabled #{link.action}#{link.html_options[:class].blank? ? '' : (' ' + link.html_options[:class])}"})) %>
18
- <% end -%>
19
- <% end -%>
6
+ <%= render :partial => 'action_group', :locals => {:action_links => action_links || active_scaffold_config.action_links.member,
7
+ :url_options => url_options,
8
+ :record => record,
9
+ :traverse_options => {:for => record},
10
+ :start_level_0_tag => '<td>',
11
+ :end_level_0_tag => '</td>'} %>
20
12
  </tr>
21
13
  </table>
22
14
  </td>
@@ -1,11 +1,9 @@
1
- <% action_links = active_scaffold_config.action_links.collection.collect
1
+ <% action_links = active_scaffold_config.action_links.collection
2
2
  unless action_links.empty? -%>
3
3
  <div class="actions">
4
- <% new_params = params_for %>
5
- <% action_links.send(nested.nil? ? :each : :reverse_each) do |link| -%>
6
- <% next if skip_action_link(link) -%>
7
- <%= render_action_link(link, new_params) -%>
8
- <% end -%>
4
+ <%= render :partial => 'action_group', :locals => {:action_links => action_links,
5
+ :url_options => params_for,
6
+ :traverse_options => nested? ? {:reverse => true} : {}} %>
9
7
  <%= loading_indicator_tag(:action => :table) %>
10
8
  </div>
11
9
  <% end %>