active_scaffold_vho 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -27,7 +27,7 @@ Jeweler::Tasks.new do |gem|
27
27
  gem.email = "activescaffold@googlegroups.com"
28
28
  gem.authors = ["Many, see README"]
29
29
  gem.add_runtime_dependency 'render_component_vho'
30
- gem.add_runtime_dependency 'rails', '~> 3.1.0'
30
+ gem.add_runtime_dependency 'rails', '>= 3.1.0'
31
31
  # Include your dependencies below. Runtime dependencies are required when using your gem,
32
32
  # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
33
33
  # gem.add_runtime_dependency 'jabber4r', '> 0.1'
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active_scaffold_vho}
8
- s.version = "3.1.1"
8
+ s.version = "3.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Many, see README"]
12
- s.date = %q{2011-12-22}
12
+ s.date = %q{2012-02-11}
13
13
  s.description = %q{Save time and headaches, and create a more easily maintainable set of pages, with ActiveScaffold. ActiveScaffold handles all your CRUD (create, read, update, delete) user interface needs, leaving you more time to focus on more challenging (and interesting!) problems.}
14
14
  s.email = %q{activescaffold@googlegroups.com}
15
15
  s.extra_rdoc_files = [
@@ -70,7 +70,6 @@ Gem::Specification.new do |s|
70
70
  "frontends/default/views/_list_calculations.html.erb",
71
71
  "frontends/default/views/_list_column_headings.html.erb",
72
72
  "frontends/default/views/_list_header.html.erb",
73
- "frontends/default/views/_list_inline_adapter.html.erb",
74
73
  "frontends/default/views/_list_messages.html.erb",
75
74
  "frontends/default/views/_list_pagination.html.erb",
76
75
  "frontends/default/views/_list_pagination_links.html.erb",
@@ -186,11 +185,9 @@ Gem::Specification.new do |s|
186
185
  "lib/active_scaffold/data_structures/set.rb",
187
186
  "lib/active_scaffold/data_structures/sorting.rb",
188
187
  "lib/active_scaffold/engine.rb",
189
- "lib/active_scaffold/extensions/action_controller_rendering.rb",
190
188
  "lib/active_scaffold/extensions/action_view_rendering.rb",
191
189
  "lib/active_scaffold/extensions/action_view_resolver.rb",
192
190
  "lib/active_scaffold/extensions/active_association_reflection.rb",
193
- "lib/active_scaffold/extensions/active_record_offset.rb",
194
191
  "lib/active_scaffold/extensions/array.rb",
195
192
  "lib/active_scaffold/extensions/localize.rb",
196
193
  "lib/active_scaffold/extensions/name_option_for_datetime.rb",
@@ -370,14 +367,14 @@ Gem::Specification.new do |s|
370
367
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
371
368
  s.add_development_dependency(%q<rcov>, [">= 0"])
372
369
  s.add_runtime_dependency(%q<render_component_vho>, [">= 0"])
373
- s.add_runtime_dependency(%q<rails>, ["~> 3.1.0"])
370
+ s.add_runtime_dependency(%q<rails>, [">= 3.1.0"])
374
371
  else
375
372
  s.add_dependency(%q<shoulda>, [">= 0"])
376
373
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
377
374
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
378
375
  s.add_dependency(%q<rcov>, [">= 0"])
379
376
  s.add_dependency(%q<render_component_vho>, [">= 0"])
380
- s.add_dependency(%q<rails>, ["~> 3.1.0"])
377
+ s.add_dependency(%q<rails>, [">= 3.1.0"])
381
378
  end
382
379
  else
383
380
  s.add_dependency(%q<shoulda>, [">= 0"])
@@ -385,7 +382,7 @@ Gem::Specification.new do |s|
385
382
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
386
383
  s.add_dependency(%q<rcov>, [">= 0"])
387
384
  s.add_dependency(%q<render_component_vho>, [">= 0"])
388
- s.add_dependency(%q<rails>, ["~> 3.1.0"])
385
+ s.add_dependency(%q<rails>, [">= 3.1.0"])
389
386
  end
390
387
  end
391
388
 
@@ -241,6 +241,16 @@ $(document).ready(function() {
241
241
  });
242
242
  return true;
243
243
  });
244
+ $('tr.inline-adapter-autoopen').live('as:list_row_loaded', function(event) {
245
+ var actionlink_id = $(event.target).attr('data-actionlinkid');
246
+ if(actionlink_id) {
247
+ var action_link = ActiveScaffold.ActionLink.get(actionlink_id);
248
+ if (action_link) {
249
+ action_link.set_opened();
250
+ }
251
+ }
252
+ return true;
253
+ });
244
254
  $('form.as_form').live('ajax:before', function(event) {
245
255
  var as_form = $(this).closest("form");
246
256
  $(this).trigger('as:form_submit');
@@ -455,12 +465,17 @@ var ActiveScaffold = {
455
465
  ActiveScaffold.highlight(replaced);
456
466
  },
457
467
 
458
- replace: function(element, html) {
468
+ replace: function(element, html, disable_event_trigger) {
459
469
  if (typeof(element) == 'string') element = '#' + element;
460
470
  element = $(element);
461
- ActiveScaffold.trigger_unload_events(element.find('[data-as_load]').andSelf());
462
- var new_element = $(html).replaceAll(element);
463
- ActiveScaffold.trigger_load_events(new_element.find('[data-as_load]').andSelf());
471
+ var new_element = null;
472
+ if((typeof(disable_event_trigger) == 'boolean') && disable_event_trigger == true) {
473
+ new_element = $(html).replaceAll(element);
474
+ } else {
475
+ ActiveScaffold.trigger_unload_events(element.find('[data-as_load]').andSelf());
476
+ new_element = $(html).replaceAll(element);
477
+ ActiveScaffold.trigger_load_events(new_element.find('[data-as_load]').andSelf());
478
+ }
464
479
  return new_element;
465
480
  },
466
481
 
@@ -920,7 +935,7 @@ ActiveScaffold.ActionLink.Abstract = Class.extend({
920
935
  this.hide_target = false;
921
936
  this.position = this.tag.attr('data-position');
922
937
  this.action = this.tag.attr('data-action');
923
-
938
+
924
939
  this.tag.data('action_link', this);
925
940
  return this;
926
941
  },
@@ -979,6 +994,24 @@ ActiveScaffold.ActionLink.Abstract = Class.extend({
979
994
  this.adapter = element;
980
995
  this.adapter.addClass('as_adapter');
981
996
  this.adapter.data('action_link', this);
997
+ },
998
+ wrap_with_adapter_html: function(content) {
999
+ // players_view class missing
1000
+ var id_string = null;
1001
+ var close_label = this.scaffold().attr('data-closelabel');
1002
+ var controller = this.scaffold().attr('data-controller');
1003
+
1004
+ if (this.tag.attr('data-controller')) {
1005
+ controller = this.tag.attr('data-controller');
1006
+ }
1007
+
1008
+ if(this.target.hasClass('before-header')) {
1009
+ id_string = this.target.attr('id').replace('search', 'nested');
1010
+ } else {
1011
+ id_string = this.target.attr('id').replace('list', 'nested');
1012
+ }
1013
+
1014
+ return '<tr class="inline-adapter" id="' + id_string + '"><td colspan="99" class="inline-adapter-cell"><div class="' + this.action + '-view ' + controller + '-view view"><a class="inline-adapter-close as_cancel" title="' + close_label + '" data-remote="true" data-refresh="false" href="">' + close_label +'</a>' + content + '</div></td></tr>'
982
1015
  }
983
1016
  });
984
1017
 
@@ -989,11 +1022,13 @@ ActiveScaffold.Actions.Record = ActiveScaffold.Actions.Abstract.extend({
989
1022
  instantiate_link: function(link) {
990
1023
  var l = new ActiveScaffold.ActionLink.Record(link, this.target, this.loading_indicator);
991
1024
  var refresh = this.target.attr('data-refresh');
992
- if (refresh) l.refresh_url = refresh;
993
-
994
- if (l.position) {
995
- l.url = l.url.append_params({adapter: '_list_inline_adapter'});
996
- l.tag.attr('href', l.url);
1025
+ if (refresh) {
1026
+ l.refresh_url = refresh;
1027
+ }
1028
+
1029
+ if (l.position && l.tag.attr('data-action') == 'index') {
1030
+ l.url = l.url.append_params({embedded: true});
1031
+ l.tag.attr('href', l.url);
997
1032
  }
998
1033
  l.set = this;
999
1034
  return l;
@@ -1021,18 +1056,19 @@ ActiveScaffold.ActionLink.Record = ActiveScaffold.ActionLink.Abstract.extend({
1021
1056
  }
1022
1057
 
1023
1058
  if (this.position == 'after') {
1024
- this.target.after(content);
1059
+ this.target.after(this.wrap_with_adapter_html(content));
1025
1060
  ActiveScaffold.trigger_load_events(this.target.next().find('[data-as_load]'));
1026
1061
  this.set_adapter(this.target.next());
1027
1062
  }
1028
1063
  else if (this.position == 'before') {
1029
- this.target.before(content);
1064
+ this.target.before(this.wrap_with_adapter_html(content));
1030
1065
  ActiveScaffold.trigger_load_events(this.target.prev().find('[data-as_load]'));
1031
1066
  this.set_adapter(this.target.prev());
1032
1067
  }
1033
1068
  else {
1034
1069
  return false;
1035
1070
  }
1071
+ this.update_flash_messages('');
1036
1072
  ActiveScaffold.highlight(this.adapter.find('td'));
1037
1073
  },
1038
1074
 
@@ -1061,10 +1097,12 @@ ActiveScaffold.ActionLink.Record = ActiveScaffold.ActionLink.Abstract.extend({
1061
1097
 
1062
1098
  set_opened: function() {
1063
1099
  if (this.position == 'after') {
1064
- this.set_adapter(this.target.next());
1100
+ var new_adapter = ActiveScaffold.replace(this.target.next(), this.wrap_with_adapter_html(this.target.next().children(':first-child').html()), true);
1101
+ this.set_adapter(new_adapter);
1065
1102
  }
1066
1103
  else if (this.position == 'before') {
1067
- this.set_adapter(this.target.prev());
1104
+ var new_adapter = ActiveScaffold.replace(this.target.prev(), this.wrap_with_adapter_html(this.target.prev().children(':first-child').html()), true);
1105
+ this.set_adapter(new_adapter);
1068
1106
  }
1069
1107
  this.disable();
1070
1108
  }
@@ -1076,10 +1114,7 @@ ActiveScaffold.ActionLink.Record = ActiveScaffold.ActionLink.Abstract.extend({
1076
1114
  ActiveScaffold.Actions.Table = ActiveScaffold.Actions.Abstract.extend({
1077
1115
  instantiate_link: function(link) {
1078
1116
  var l = new ActiveScaffold.ActionLink.Table(link, this.target, this.loading_indicator);
1079
- if (l.position) {
1080
- l.url = l.url.append_params({adapter: '_list_inline_adapter'});
1081
- l.tag.attr('href', l.url);
1082
- }
1117
+
1083
1118
  return l;
1084
1119
  }
1085
1120
  });
@@ -1087,13 +1122,14 @@ ActiveScaffold.Actions.Table = ActiveScaffold.Actions.Abstract.extend({
1087
1122
  ActiveScaffold.ActionLink.Table = ActiveScaffold.ActionLink.Abstract.extend({
1088
1123
  insert: function(content) {
1089
1124
  if (this.position == 'top') {
1090
- this.target.prepend(content);
1125
+ this.target.prepend(this.wrap_with_adapter_html(content));
1091
1126
  ActiveScaffold.trigger_load_events(this.target.children().first().find('[data-as_load]'));
1092
1127
  this.set_adapter(this.target.children().first());
1093
1128
  }
1094
1129
  else {
1095
1130
  throw 'Unknown position "' + this.position + '"'
1096
1131
  }
1132
+ this.update_flash_messages('');
1097
1133
  ActiveScaffold.highlight(this.adapter.find('td').first().children());
1098
1134
  }
1099
1135
  });
@@ -314,6 +314,16 @@ document.observe("dom:loaded", function() {
314
314
  ActiveScaffold.focus_first_element_of_form(as_form);
315
315
  return true;
316
316
  });
317
+ document.on('as:list_row_loaded', 'tr.inline-adapter-autoopen', function(event, element) {
318
+ var actionlink_id = element.readAttribute('data-actionlinkid');
319
+ if(actionlink_id) {
320
+ var action_link = ActiveScaffold.ActionLink.get(actionlink_id);
321
+ if (action_link) {
322
+ action_link.set_opened();
323
+ }
324
+ }
325
+ return true;
326
+ });
317
327
  document.on('ajax:before', 'form.as_form', function(event) {
318
328
  var as_form = event.findElement('form');
319
329
  element.fire('as:form_submit');
@@ -406,12 +416,14 @@ var ActiveScaffold = {
406
416
  new_row.highlight();
407
417
  },
408
418
 
409
- replace: function(element, html) {
419
+ replace: function(element, html, disable_event_trigger) {
410
420
  element = $(element);
411
421
  var elements = element.select('[data-as_load]');
412
422
  var new_element = null;
413
423
  elements.unshift(element);
414
- ActiveScaffold.trigger_unload_events(elements);
424
+ if((typeof(disable_event_trigger) != 'boolean') || disable_event_trigger === false) {
425
+ ActiveScaffold.trigger_unload_events(elements);
426
+ }
415
427
  if (html.startsWith('<tr')) {
416
428
  new_element = new Element('tbody').update(html);
417
429
  } else {
@@ -421,7 +433,9 @@ var ActiveScaffold = {
421
433
  Element.replace(element, new_element);
422
434
  elements = new_element.select('[data-as_load]');
423
435
  elements.unshift(new_element);
424
- ActiveScaffold.trigger_load_events(elements);
436
+ if((typeof(disable_event_trigger) != 'boolean') || disable_event_trigger === false) {
437
+ ActiveScaffold.trigger_load_events(elements);
438
+ }
425
439
  return new_element;
426
440
  },
427
441
 
@@ -611,7 +625,7 @@ var ActiveScaffold = {
611
625
  if (element) {
612
626
  if (options.is_subform == false) {
613
627
  ActiveScaffold.trigger_unload_events(new Array(element.up('li.form-element')));
614
- this.replace(element.up('dl'), content);
628
+ element = this.replace(element.up('dl'), content);
615
629
  ActiveScaffold.trigger_load_events(new Array(element.up('li.form-element')));
616
630
  } else {
617
631
  this.replace_html(element, content);
@@ -879,6 +893,25 @@ ActiveScaffold.ActionLink.Abstract = Class.create({
879
893
  this.adapter = element;
880
894
  this.adapter.addClassName('as_adapter');
881
895
  this.adapter.store('action_link', this);
896
+ },
897
+
898
+ wrap_with_adapter_html: function(content) {
899
+ // players_view class missing
900
+ var id_string = null;
901
+ var close_label = this.scaffold().readAttribute('data-closelabel');
902
+ var controller = this.scaffold().readAttribute('data-controller');
903
+
904
+ if (this.tag.readAttribute('data-controller')) {
905
+ controller = this.tag.readAttribute('data-controller');
906
+ }
907
+
908
+ if(this.target.hasClassName('before-header')) {
909
+ id_string = this.target.readAttribute('id').replace('search', 'nested');
910
+ } else {
911
+ id_string = this.target.readAttribute('id').replace('list', 'nested');
912
+ }
913
+
914
+ return '<tr class="inline-adapter" id="' + id_string + '"><td colspan="99" class="inline-adapter-cell"><div class="' + this.action + '-view ' + controller + '-view view"><a class="inline-adapter-close as_cancel" title="' + close_label + '" data-remote="true" data-refresh="false" href="">' + close_label +'</a>' + content + '</div></td></tr>'
882
915
  }
883
916
  });
884
917
 
@@ -889,10 +922,10 @@ ActiveScaffold.Actions.Record = Class.create(ActiveScaffold.Actions.Abstract, {
889
922
  instantiate_link: function(link) {
890
923
  var l = new ActiveScaffold.ActionLink.Record(link, this.target, this.loading_indicator);
891
924
  if (this.target.hasAttribute('data-refresh') && !this.target.readAttribute('data-refresh').blank()) l.refresh_url = this.target.readAttribute('data-refresh');
892
-
893
- if (l.position) {
894
- l.url = l.url.append_params({adapter: '_list_inline_adapter'});
895
- l.tag.href = l.url;
925
+
926
+ if (l.position && l.tag.hasAttribute('data-action') && l.tag.readAttribute('data-action') == "index") {
927
+ l.url = l.url.append_params({embedded: true});
928
+ l.tag.href = l.url;
896
929
  }
897
930
  l.set = this;
898
931
  return l;
@@ -919,18 +952,19 @@ ActiveScaffold.ActionLink.Record = Class.create(ActiveScaffold.ActionLink.Abstra
919
952
  }
920
953
 
921
954
  if (this.position == 'after') {
922
- this.target.insert({after:content});
955
+ this.target.insert({after:this.wrap_with_adapter_html(content)});
923
956
  ActiveScaffold.trigger_load_events(this.target.next().select('[data-as_load]'));
924
957
  this.set_adapter(this.target.next());
925
958
  }
926
959
  else if (this.position == 'before') {
927
- this.target.insert({before:content});
960
+ this.target.insert({before:this.wrap_with_adapter_html(content)});
928
961
  ActiveScaffold.trigger_load_events(this.target.previous().select('[data-as_load]'));
929
962
  this.set_adapter(this.target.previous());
930
963
  }
931
964
  else {
932
965
  return false;
933
966
  }
967
+ this.update_flash_messages();
934
968
  this.adapter.down('td').down().highlight();
935
969
  },
936
970
 
@@ -957,10 +991,12 @@ ActiveScaffold.ActionLink.Record = Class.create(ActiveScaffold.ActionLink.Abstra
957
991
 
958
992
  set_opened: function() {
959
993
  if (this.position == 'after') {
960
- this.set_adapter(this.target.next());
994
+ var new_adapter = ActiveScaffold.replace(this.target.next(), this.wrap_with_adapter_html(this.target.next().childElements().first().innerHTML), true);
995
+ this.set_adapter(new_adapter);
961
996
  }
962
997
  else if (this.position == 'before') {
963
- this.set_adapter(this.target.previous());
998
+ var new_adapter = ActiveScaffold.replace(this.target.previous(), this.wrap_with_adapter_html(this.target.previous().childElements().first().innerHTML), true);
999
+ this.set_adapter(new_adapter);
964
1000
  }
965
1001
  this.disable();
966
1002
  }
@@ -972,10 +1008,7 @@ ActiveScaffold.ActionLink.Record = Class.create(ActiveScaffold.ActionLink.Abstra
972
1008
  ActiveScaffold.Actions.Table = Class.create(ActiveScaffold.Actions.Abstract, {
973
1009
  instantiate_link: function(link) {
974
1010
  var l = new ActiveScaffold.ActionLink.Table(link, this.target, this.loading_indicator);
975
- if (l.position) {
976
- l.url = l.url.append_params({adapter: '_list_inline_adapter'});
977
- l.tag.href = l.url;
978
- }
1011
+
979
1012
  return l;
980
1013
  }
981
1014
  });
@@ -983,13 +1016,14 @@ ActiveScaffold.Actions.Table = Class.create(ActiveScaffold.Actions.Abstract, {
983
1016
  ActiveScaffold.ActionLink.Table = Class.create(ActiveScaffold.ActionLink.Abstract, {
984
1017
  insert: function(content) {
985
1018
  if (this.position == 'top') {
986
- this.target.insert({top:content});
1019
+ this.target.insert({top:this.wrap_with_adapter_html(content)});
987
1020
  ActiveScaffold.trigger_load_events(this.target.immediateDescendants().first().select('[data-as_load]'));
988
1021
  this.set_adapter(this.target.immediateDescendants().first());
989
1022
  }
990
1023
  else {
991
1024
  throw 'Unknown position "' + this.position + '"'
992
1025
  }
1026
+ this.update_flash_messages();
993
1027
  this.adapter.down('td').down().highlight();
994
1028
  }
995
1029
  });
@@ -9,5 +9,5 @@ action_links ||= active_scaffold_config.action_links.member
9
9
  <tr class="record <%= tr_class %>" id="<%= element_row_id(:action => :list, :id => record.id) %>" data-refresh="<%= url_for(params_for(:action => :row, :id => record.id, :_method => :get, :escape => false)).html_safe %>" data-as_load="tr">
10
10
  <%= render :partial => 'list_record_columns', :locals => {:record => record, :columns => columns} %>
11
11
  <%= render :partial => 'list_actions', :locals => {:record => record, :url_options => url_options, :action_links => action_links} unless action_links.empty? %>
12
- <%= render_nested_view(action_links, url_options, record) unless @nested_auto_open.nil? %>
13
- </tr>
12
+ </tr>
13
+ <%= render_nested_view(action_links, url_options, record) unless @nested_auto_open.nil? %>
@@ -1,4 +1,4 @@
1
- <div id="<%= active_scaffold_id -%>" class="<%= as_main_div_class %>" <%= "data-eid=#{id_from_controller(params[:eid])}" if params[:eid]%>>
1
+ <div id="<%= active_scaffold_id -%>" class="<%= as_main_div_class %>" <%= "data-eid=#{id_from_controller(params[:eid])}" if params[:eid]%> data-closelabel="<%=as_(:close).html_safe%>" data-controller=<%="#{params[:controller]}"%>>
2
2
  <div class="active-scaffold-header">
3
3
  <%= render :partial => 'list_header' %>
4
4
  </div>
@@ -32,9 +32,7 @@ module ActiveScaffold::Actions
32
32
  end
33
33
  end
34
34
  def list_respond_to_js
35
- if params[:adapter]
36
- render(:partial => 'list_with_header')
37
- elsif params[:embedded]
35
+ if params[:embedded]
38
36
  params.delete(:embedded)
39
37
  render(:partial => 'list_with_header')
40
38
  else
@@ -34,7 +34,7 @@ module ActiveScaffold
34
34
  '%a' => 'D',
35
35
  '%A' => 'DD',
36
36
  '%b' => 'M',
37
- '$B' => 'MM',
37
+ '%B' => 'MM',
38
38
  '%d' => 'dd',
39
39
  '%e' => 'd',
40
40
  '%j' => 'oo',
@@ -16,7 +16,7 @@ module ActiveScaffold::Config
16
16
 
17
17
  # the ActionLink for this action
18
18
  cattr_accessor :link
19
- @@link = ActiveScaffold::DataStructures::ActionLink.new('destroy', :label => :delete, :type => :member, :confirm => :are_you_sure_to_delete, :method => :delete, :crud_type => :delete, :position => false, :parameters => {:destroy_action => true}, :security_method => :delete_authorized?)
19
+ @@link = ActiveScaffold::DataStructures::ActionLink.new('destroy', :label => :delete, :type => :member, :confirm => :are_you_sure_to_delete, :method => :delete, :crud_type => :delete, :position => false, :parameters => {:destroy_action => true}, :security_method => :delete_authorized?, :ignore_method => :delete_ignore?)
20
20
 
21
21
  # whether we should refresh list after destroy or not
22
22
  cattr_accessor :refresh_list
@@ -128,6 +128,11 @@ module ActiveScaffold::Config
128
128
  attr_accessor :nested_auto_open
129
129
 
130
130
  class UserSettings < UserSettings
131
+ def initialize(conf, storage, params)
132
+ super(conf,storage,params)
133
+ @sorting = nil
134
+ end
135
+
131
136
  # This label has alread been localized.
132
137
  def label
133
138
  @session[:label] ? @session[:label] : @conf.label
@@ -159,17 +164,20 @@ module ActiveScaffold::Config
159
164
  end
160
165
 
161
166
  def sorting
162
- # we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
163
- @session['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] and @params['sort_direction']
164
- @session['sort'] = nil if @params['sort_direction'] == 'reset'
165
-
166
- if @session['sort']
167
- sorting = @conf.sorting.clone
168
- sorting.set(*@session['sort'])
169
- return sorting
170
- else
171
- return default_sorting
167
+ if @sorting.nil?
168
+ # we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
169
+ @session['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] and @params['sort_direction']
170
+ @session['sort'] = nil if @params['sort_direction'] == 'reset'
171
+
172
+ if @session['sort']
173
+ sorting = @conf.sorting.clone
174
+ sorting.set(*@session['sort'])
175
+ @sorting = sorting
176
+ else
177
+ @sorting = default_sorting
178
+ end
172
179
  end
180
+ @sorting
173
181
  end
174
182
 
175
183
  def count_includes
@@ -173,7 +173,7 @@ module ActiveScaffold::DataStructures
173
173
  protected
174
174
 
175
175
  def skip_action_link(controller, link, *args)
176
- (!link.ignore_method.nil? and controller.try(link.ignore_method, *args)) || ((link.security_method_set? or controller.respond_to? link.security_method) and !controller.send(link.security_method, *args))
176
+ (!link.ignore_method.nil? && controller.respond_to?(link.ignore_method) && controller.send(link.ignore_method, *args)) || ((link.security_method_set? or controller.respond_to? link.security_method) and !controller.send(link.security_method, *args))
177
177
  end
178
178
 
179
179
  # called during clone or dup. makes the clone/dup deeper.
@@ -311,7 +311,7 @@ module ActiveScaffold::DataStructures
311
311
  self.sort = false
312
312
  else
313
313
  if self.singular_association?
314
- self.sort = {:method => "#{self.name}.to_s"}
314
+ self.sort = {:method => "#{self.name}.to_label"}
315
315
  elsif self.plural_association?
316
316
  self.sort = {:method => "#{self.name}.join(',')"}
317
317
  else
@@ -3,6 +3,33 @@ module ActiveScaffold
3
3
  # not sure if it is a must though...
4
4
  #module Rails
5
5
  class Engine < ::Rails::Engine
6
+ initializer "initialize_active_scaffold" do
7
+ # TODO: clean up extensions. some could be organized for autoloading, and others could be removed entirely.
8
+ ActiveSupport.on_load(:action_controller) do
9
+ ['array', 'localize', 'nil_id_in_url_params', 'paginator_extensions', 'routing_mapper'].each do |extension|
10
+ require "#{File.dirname __FILE__}/extensions/#{extension}.rb"
11
+ end
12
+ include ActiveScaffold
13
+ include RespondsToParent
14
+ include ActiveScaffold::Helpers::ControllerHelpers
15
+ class_eval {include ActiveRecordPermissions::ModelUserAccess::Controller}
16
+ end
17
+
18
+ ActiveSupport.on_load(:action_view) do
19
+ ['name_option_for_datetime', 'action_view_rendering', 'action_view_resolver', 'usa_state'].each do |extension|
20
+ require "#{File.dirname __FILE__}/extensions/#{extension}.rb"
21
+ end
22
+ include ActiveScaffold::Helpers::ViewHelpers
23
+ end
24
+
25
+ ActiveSupport.on_load(:active_record) do
26
+ ['active_association_reflection', 'reverse_associations', 'to_label', 'unsaved_record'].each do |extension|
27
+ require "#{File.dirname __FILE__}/extensions/#{extension}.rb"
28
+ end
29
+ class_eval {include ActiveRecordPermissions::ModelUserAccess::Model}
30
+ class_eval {include ActiveRecordPermissions::Permissions}
31
+ end
32
+ end
6
33
  end
7
34
  #end
8
35
  end
@@ -5,7 +5,11 @@ module ActionView
5
5
  def find_all_templates(name, partial = false, locals = {})
6
6
  prefixes.collect do |prefix|
7
7
  @view_paths.collect do |resolver|
8
- temp_args = *args_for_lookup(name, [prefix], partial, locals)
8
+ if Rails::VERSION::MINOR == 1
9
+ temp_args = *args_for_lookup(name, [prefix], partial, locals)
10
+ else
11
+ temp_args = *args_for_lookup(name, [prefix], partial, locals, {})
12
+ end
9
13
  temp_args[1] = temp_args[1][0]
10
14
  resolver.find_all(*temp_args)
11
15
  end
@@ -244,8 +244,7 @@ module ActiveScaffold
244
244
 
245
245
  # add functionality for overriding subform partials from association class path
246
246
  def override_subform_partial?(column, subform_partial)
247
- path, partial_name = partial_pieces(override_subform_partial(column, subform_partial))
248
- template_exists?(partial_name, path)
247
+ template_exists?(override_subform_partial(column, subform_partial), true)
249
248
  end
250
249
 
251
250
  def override_subform_partial(column, subform_partial)
@@ -253,22 +252,26 @@ module ActiveScaffold
253
252
  end
254
253
 
255
254
  def override_form_field_partial?(column)
256
- path, partial_name = partial_pieces(override_form_field_partial(column))
257
- template_exists?(partial_name, path)
255
+ template_exists?(override_form_field_partial(column), true)
258
256
  end
259
257
 
260
258
  # the naming convention for overriding form fields with partials
261
259
  def override_form_field_partial(column)
262
- "#{column.name}_form_column"
260
+ path = active_scaffold_controller_for(column.active_record_class).controller_path
261
+ File.join(path, "#{clean_column_name(column.name)}_form_column")
263
262
  end
264
263
 
265
- def override_form_field?(column)
266
- respond_to?(override_form_field(column))
264
+ def override_form_field(column)
265
+ method_with_class = override_form_field_name(column, true)
266
+ return method_with_class if respond_to?(method_with_class)
267
+ method = override_form_field_name(column)
268
+ method if respond_to?(method)
267
269
  end
270
+ alias_method :override_form_field?, :override_form_field
268
271
 
269
272
  # the naming convention for overriding form fields with helpers
270
- def override_form_field(column)
271
- "#{column.name}_form_column"
273
+ def override_form_field_name(column, class_prefix = false)
274
+ "#{clean_class_name(column.active_record_class.name) + '_' if class_prefix}#{clean_column_name(column.name)}_form_column"
272
275
  end
273
276
 
274
277
  def override_input?(form_ui)
@@ -350,19 +350,19 @@ module ActiveScaffold
350
350
  end
351
351
  end
352
352
  end
353
-
353
+
354
354
  def render_nested_view(action_links, url_options, record)
355
355
  rendered = []
356
+ link_id = nil
356
357
  action_links.member.each do |link|
357
358
  if link.nested_link? && link.column && @nested_auto_open[link.column.name] && @records.length <= @nested_auto_open[link.column.name] && controller.respond_to?(:render_component_into_view)
358
- link_url_options = {:adapter => '_list_inline_adapter', :format => :js}.merge(action_link_url_options(link, url_options, record, options = {:reuse_eid => true}))
359
+ link_url_options = {:embedded => true, :format => :js}.merge(action_link_url_options(link, url_options, record, options = {:reuse_eid => true}))
359
360
  link_id = get_action_link_id(link_url_options, record, link.column)
360
- rendered << (controller.send(:render_component_into_view, link_url_options) + javascript_tag("ActiveScaffold.ActionLink.get('#{link_id}').set_opened();"))
361
- end
361
+ rendered << (controller.send(:render_component_into_view, link_url_options))
362
+ end
362
363
  end
363
- rendered.join(' ').html_safe
364
- end
365
-
364
+ content_tag(:tr, content_tag(:td, rendered.join(' ').html_safe), :class => "inline-adapter-autoopen", 'data-actionlinkid' => link_id, 'data-as_load'=>"tr");
365
+ end
366
366
  end
367
367
  end
368
368
  end
@@ -42,26 +42,10 @@ module ActiveScaffold
42
42
  end
43
43
  end
44
44
 
45
- def partial_pieces(partial_path)
46
- if partial_path.include?('/')
47
- return File.dirname(partial_path), File.basename(partial_path)
48
- else
49
- return controller.class.controller_path, partial_path
50
- end
51
- end
52
-
53
45
  # This is the template finder logic, keep it updated with however we find stuff in rails
54
46
  # currently this very similar to the logic in ActionBase::Base.render for options file
55
- # TODO: Work with rails core team to find a better way to check for this.
56
- # Not working so far for rais 3.1
57
- def template_exists?(template_name, path)
58
- begin
59
- method = 'find_template'
60
- #self.view_paths.send(method, template_name)
61
- return false
62
- rescue ActionView::MissingTemplate => e
63
- return false
64
- end
47
+ def template_exists?(template_name, partial = false)
48
+ lookup_context.exists? template_name, '', partial
65
49
  end
66
50
 
67
51
  def generate_temporary_id
@@ -149,7 +133,7 @@ module ActiveScaffold
149
133
  end
150
134
 
151
135
  def skip_action_link(link, *args)
152
- (!link.ignore_method.nil? and controller.try(link.ignore_method, *args)) || ((link.security_method_set? or controller.respond_to? link.security_method) and !controller.send(link.security_method, *args))
136
+ (!link.ignore_method.nil? && controller.respond_to?(link.ignore_method) && controller.send(link.ignore_method, *args)) || ((link.security_method_set? or controller.respond_to? link.security_method) and !controller.send(link.security_method, *args))
153
137
  end
154
138
 
155
139
  def render_action_link(link, url_options, record = nil, html_options = {})
@@ -190,6 +174,7 @@ module ActiveScaffold
190
174
 
191
175
  html_options['data-confirm'] = link.confirm(record.try(:to_label)) if link.confirm?
192
176
  html_options['data-position'] = link.position if link.position and link.inline?
177
+ html_options['data-controller'] = link.controller.to_s if link.controller
193
178
  html_options[:class] += ' as_action' if link.inline?
194
179
  html_options['data-action'] = link.action if link.inline?
195
180
  if link.popup?
@@ -337,6 +322,14 @@ module ActiveScaffold
337
322
  value
338
323
  end
339
324
 
325
+ def clean_column_name(name)
326
+ name.to_s.gsub('?', '')
327
+ end
328
+
329
+ def clean_class_name(name)
330
+ name.underscore.gsub('/', '_')
331
+ end
332
+
340
333
  def active_scaffold_error_messages_for(*params)
341
334
  options = params.extract_options!.symbolize_keys
342
335
  options.reverse_merge!(:container_tag => :div, :list_type => :ul)
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -104,14 +104,16 @@ module ActiveScaffold
104
104
  end
105
105
 
106
106
  def check_input_device
107
- if request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(iPhone|iPod|iPad)/i]
108
- session[:input_device_type] = 'TOUCH'
109
- session[:hover_supported] = false
110
- else
111
- session[:input_device_type] = 'MOUSE'
112
- session[:hover_supported] = true
113
- end if session[:input_device_type].nil?
114
- end
107
+ if self.class.uses_active_scaffold?
108
+ if request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(iPhone|iPod|iPad)/i]
109
+ session[:input_device_type] = 'TOUCH'
110
+ session[:hover_supported] = false
111
+ else
112
+ session[:input_device_type] = 'MOUSE'
113
+ session[:hover_supported] = true
114
+ end if session[:input_device_type].nil?
115
+ end
116
+ end
115
117
 
116
118
  def touch_device?
117
119
  session[:input_device_type] == 'TOUCH'
@@ -1,14 +1,2 @@
1
- # TODO: clean up extensions. some could be organized for autoloading, and others could be removed entirely.
2
- Dir["#{File.dirname __FILE__}/active_scaffold/extensions/*.rb"].each { |file| require file }
3
-
4
- ActionController::Base.send(:include, ActiveScaffold)
5
- ActionController::Base.send(:include, RespondsToParent)
6
- ActionController::Base.send(:include, ActiveScaffold::Helpers::ControllerHelpers)
7
- ActionView::Base.send(:include, ActiveScaffold::Helpers::ViewHelpers)
8
-
9
- ActionController::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Controller}
10
- ActiveRecord::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Model}
11
- ActiveRecord::Base.class_eval {include ActiveRecordPermissions::Permissions}
12
-
13
1
  I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'active_scaffold', 'locale', '*.{rb,yml}')]
14
2
  #ActiveScaffold.js_framework = :prototype
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 3
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  segments_generated: true
10
- version: 3.1.1
10
+ version: 3.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Many, see README
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-22 00:00:00 +01:00
18
+ date: 2012-02-11 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -97,7 +97,7 @@ dependencies:
97
97
  requirement: &id006 !ruby/object:Gem::Requirement
98
98
  none: false
99
99
  requirements:
100
- - - ~>
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  segments:
103
103
  - 3
@@ -171,7 +171,6 @@ files:
171
171
  - frontends/default/views/_list_calculations.html.erb
172
172
  - frontends/default/views/_list_column_headings.html.erb
173
173
  - frontends/default/views/_list_header.html.erb
174
- - frontends/default/views/_list_inline_adapter.html.erb
175
174
  - frontends/default/views/_list_messages.html.erb
176
175
  - frontends/default/views/_list_pagination.html.erb
177
176
  - frontends/default/views/_list_pagination_links.html.erb
@@ -287,11 +286,9 @@ files:
287
286
  - lib/active_scaffold/data_structures/set.rb
288
287
  - lib/active_scaffold/data_structures/sorting.rb
289
288
  - lib/active_scaffold/engine.rb
290
- - lib/active_scaffold/extensions/action_controller_rendering.rb
291
289
  - lib/active_scaffold/extensions/action_view_rendering.rb
292
290
  - lib/active_scaffold/extensions/action_view_resolver.rb
293
291
  - lib/active_scaffold/extensions/active_association_reflection.rb
294
- - lib/active_scaffold/extensions/active_record_offset.rb
295
292
  - lib/active_scaffold/extensions/array.rb
296
293
  - lib/active_scaffold/extensions/localize.rb
297
294
  - lib/active_scaffold/extensions/name_option_for_datetime.rb
@@ -420,7 +417,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
420
417
  requirements:
421
418
  - - ">="
422
419
  - !ruby/object:Gem::Version
423
- hash: -1540629792815748302
420
+ hash: 4142914168205785236
424
421
  segments:
425
422
  - 0
426
423
  segments_generated: true
@@ -1,10 +0,0 @@
1
- <%# nested_id, allows us to remove a nested scaffold programmatically %>
2
- <tr class="inline-adapter" id="<%= element_row_id :action => :nested %>">
3
- <td colspan="99" class="inline-adapter-cell">
4
- <div class="<%= "#{params[:action]}-view" if params[:action] %> <%= "#{params[:associations] ? params[:associations] : params[:controller]}-view" %> view">
5
- <%= link_to(as_(:close), '', :class => 'inline-adapter-close as_cancel', :remote => true, :title => as_(:close), 'data-refresh' => (action_name == 'index' ? true : false)) -%>
6
- <%= payload -%>
7
- </div>
8
- </td>
9
- </tr>
10
- <%= javascript_tag("var action_link = ActiveScaffold.ActionLink.get('#{element_row_id(:action => :nested)}'); if (action_link) action_link.update_flash_messages('#{escape_javascript(render(:partial => 'messages').strip)}');") %>
@@ -1,22 +0,0 @@
1
- # wrap the action rendering for ActiveScaffold controllers
2
- module ActionController #:nodoc:
3
- class Base
4
- def render_with_active_scaffold(*args, &block)
5
- if self.class.uses_active_scaffold? and params[:adapter] and @rendering_adapter.nil?
6
- @rendering_adapter = true # recursion control
7
- # if we need an adapter, then we render the actual stuff to a string and insert it into the adapter template
8
- opts = args.blank? ? Hash.new : args.first
9
- render :partial => params[:adapter][1..-1],
10
- :locals => {:payload => render_to_string(opts.merge(:layout => false), &block).html_safe},
11
- :use_full_path => true, :layout => false
12
- @rendering_adapter = nil # recursion control
13
- else
14
- render_without_active_scaffold(*args, &block)
15
- end
16
- end
17
- alias_method_chain :render, :active_scaffold
18
-
19
- # Rails 2.x implementation is post-initialization on :active_scaffold method
20
- end
21
- end
22
-
@@ -1,12 +0,0 @@
1
- # Bugfix: Team.offset(1).limit(1) throws an error
2
- ActiveRecord::Base.instance_eval do
3
- def offset(*args, &block)
4
- scoped.__send__(:offset, *args, &block)
5
- rescue NoMethodError
6
- if scoped.nil?
7
- 'depends on :allow_nil'
8
- else
9
- raise
10
- end
11
- end
12
- end