active_scaffold 3.7.10 → 3.7.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +14 -0
  3. data/app/assets/javascripts/jquery/active_scaffold.js +52 -31
  4. data/app/assets/stylesheets/active_scaffold_colors.scss +7 -0
  5. data/app/assets/stylesheets/active_scaffold_layout.css +30 -4
  6. data/app/views/active_scaffold_overrides/_list.html.erb +2 -9
  7. data/app/views/active_scaffold_overrides/_list_inline_adapter.html.erb +14 -3
  8. data/app/views/active_scaffold_overrides/_list_messages.html.erb +2 -11
  9. data/app/views/active_scaffold_overrides/_list_messages_content.html.erb +8 -0
  10. data/app/views/active_scaffold_overrides/_new_record.js.erb +1 -1
  11. data/app/views/active_scaffold_overrides/_popup_adapter.html.erb +20 -0
  12. data/app/views/active_scaffold_overrides/_refresh_list.js.erb +1 -1
  13. data/app/views/active_scaffold_overrides/_row.html.erb +1 -1
  14. data/app/views/active_scaffold_overrides/add_existing.js.erb +1 -1
  15. data/app/views/active_scaffold_overrides/on_action_update.js.erb +1 -1
  16. data/app/views/active_scaffold_overrides/on_update.js.erb +2 -2
  17. data/app/views/active_scaffold_overrides/row.js.erb +1 -1
  18. data/app/views/active_scaffold_overrides/update_row.js.erb +1 -1
  19. data/lib/active_scaffold/data_structures/action_link.rb +5 -2
  20. data/lib/active_scaffold/data_structures/action_link_separator.rb +13 -0
  21. data/lib/active_scaffold/data_structures/action_links.rb +14 -8
  22. data/lib/active_scaffold/helpers/action_link_helpers.rb +31 -14
  23. data/lib/active_scaffold/helpers/human_condition_helpers.rb +9 -9
  24. data/lib/active_scaffold/helpers/list_column_helpers.rb +4 -0
  25. data/lib/active_scaffold/version.rb +2 -2
  26. data/lib/active_scaffold.rb +5 -1
  27. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cf15686cc7fb67b4b58b015fa13c13e905f84d4842706c5c61a908172ad5cf6
4
- data.tar.gz: e5a12dabc7495c540becf66a4d17cf248dce91d8745d7055dc449d2894e63237
3
+ metadata.gz: d5d2e7260966fbf6c4232d7a9750ccde96ba04bc234b770aedd47f934ac5274d
4
+ data.tar.gz: 4b8d78f9e17a958ea0cf6486c5ea913a3afda356fe0fbefdcb1acce76e175e11
5
5
  SHA512:
6
- metadata.gz: 2f5d694e309c6925491b347ec2f28061af1a0107b70caad1fbc3aa575e15d6d53137a5aa1a52f61f7bda9d5bb6b8d8880c461bb2b06d264001911bb7de59295f
7
- data.tar.gz: c344f0f8e5e1461d5f73677a1297bc21a614a248d787a89c8045cf58deebe8741558be2058b5742e81fb491cb379f28ce5762740555ebd49dc1ec4ae5929fce5
6
+ metadata.gz: 2b1634e907a0e0a2baae5dff8c6c4ca468f2684bf7c880a7d5413594c2cb06d12e2e5a9b8e53029b7492ca28d598f0db4e9c821c9bdcda818969e6ff5f13b892
7
+ data.tar.gz: 622b7f77b49a1cae067296a11df2e9fb93adb7ba8efceeafa9530cbb3cc1b9ed1f84ac8210ea323203fefc521f1a0fb76c58c613cedba6a2c0ea91471844c389
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,17 @@
1
+ = 3.7.11.1
2
+ - Fix action link on association column named record
3
+
4
+ = 3.7.11
5
+ - Add partial list_messages_content to reduce code duplication, and better support replacing list view with other way to render records
6
+ - Support selector for records body in create_record_row JS method, better support replacing list view with other way to render records
7
+ - Improve detection of member action links when list view is replaced with other structure, based on 'record' html class, instead of tags
8
+ - Support :table position for member action links, replacing the whole table
9
+ - Support changing the view partial used to render a record, default to 'list_record', better support refreshing a record when list view is replaced with other way to render records
10
+ - Support separators in action links
11
+ - Support :popup position, using jquery-ui dialog, but can be replaced with other library overriding ActiveScaffold.open_popup and ActiveScaffold.close_popup JS functions
12
+ - Use column.label in human conditions, same as form
13
+ - Don't overlap 'click to reset' with long human conditions message
14
+
1
15
  = 3.7.10
2
16
  - Move code from on_create.js.erb to partials, so it's easier to change parts, e.g. how new record is rendered
3
17
  - Don't reload after deleting last record if pagination is disabled
@@ -790,7 +790,7 @@
790
790
 
791
791
  create_record_row: function(active_scaffold_id, html, options) {
792
792
  if (typeof(active_scaffold_id) == 'string') active_scaffold_id = '#' + active_scaffold_id;
793
- var tbody = jQuery(active_scaffold_id).find('tbody.records').first(), new_row;
793
+ var tbody = jQuery(active_scaffold_id).find(options.body_selector || 'tbody.records').first(), new_row;
794
794
 
795
795
  if (options.insert_at == 'top') {
796
796
  tbody.prepend(html);
@@ -830,10 +830,10 @@
830
830
  });
831
831
  },
832
832
 
833
- delete_record_row: function(row, page_reload_url) {
833
+ delete_record_row: function(row, page_reload_url, body_selector) {
834
834
  if (typeof(row) == 'string') row = '#' + row;
835
835
  row = jQuery(row);
836
- var tbody = row.closest('tbody.records');
836
+ var tbody = row.closest(body_selector || 'tbody.records');
837
837
 
838
838
  row.find('a.disabled').each(function() {;
839
839
  var action_link = ActiveScaffold.ActionLink.get(this);
@@ -1219,8 +1219,21 @@
1219
1219
  $footer.removeClass('floating');
1220
1220
  if ($form.visible(true) && !$footer.visible(true)) $footer.addClass('floating');
1221
1221
  });
1222
- }
1222
+ },
1223
+
1224
+ open_popup: function(content, link) {
1225
+ var element = jQuery(content).dialog({
1226
+ modal: true,
1227
+ close: function() { link.close(); },
1228
+ width: ActiveScaffold.config.popup_width || '80%'
1229
+ });
1230
+ link.set_adapter(element);
1231
+ },
1223
1232
 
1233
+ close_popup: function(link, callback) {
1234
+ link.adapter.dialog('close');
1235
+ if (callback) callback();
1236
+ }
1224
1237
  }
1225
1238
 
1226
1239
 
@@ -1275,18 +1288,15 @@
1275
1288
  if (element.length > 0) {
1276
1289
  element.data(); // $ 1.4.2 workaround
1277
1290
  if (typeof(element.data('action_link')) === 'undefined' && !element.hasClass('as_adapter')) {
1278
- var parent = element.closest('.actions');
1279
- if (parent.length === 0 || parent.is('td')) {
1280
- // maybe an column action_link
1281
- parent = element.closest('tr.record');
1282
- }
1283
- if (parent.is('tr')) {
1291
+ var parent = element.parent().closest('.record');
1292
+ if (parent.length === 0) parent = element.parent().closest('.actions');
1293
+ if (parent.is('.record')) {
1284
1294
  // record action
1285
1295
  var target = parent.find('a.as_action');
1286
- var loading_indicator = parent.find('td.actions .loading-indicator');
1296
+ var loading_indicator = parent.find('.actions .loading-indicator');
1287
1297
  if (!loading_indicator.length) loading_indicator = element.parent().find('.loading-indicator');
1288
1298
  new ActiveScaffold.Actions.Record(target, parent, loading_indicator);
1289
- } else if (parent && parent.is('div')) {
1299
+ } else if (parent.is('.active-scaffold-header .actions')) {
1290
1300
  //table action
1291
1301
  new ActiveScaffold.Actions.Table(parent.find('a.as_action'), parent.closest('div.active-scaffold').find('tbody.before-header').first(), parent.find('.loading-indicator').first());
1292
1302
  }
@@ -1323,14 +1333,18 @@
1323
1333
  },
1324
1334
 
1325
1335
  close: function() {
1326
- if (this.adapter) {
1327
- var link = this;
1328
- ActiveScaffold.remove(this.adapter, function() {
1329
- link.enable();
1330
- if (link.hide_target) link.target.show();
1331
- if (link.hide_content) link.content.show();
1332
- if (ActiveScaffold.config.scroll_on_close) ActiveScaffold.scroll_to(link.target.attr('id'), ActiveScaffold.config.scroll_on_close == 'checkInViewport');
1333
- });
1336
+ var link = this, callback = function() {
1337
+ link.enable();
1338
+ if (link.hide_target) link.target.show();
1339
+ if (link.hide_content) link.content.show();
1340
+ if (ActiveScaffold.config.scroll_on_close) {
1341
+ ActiveScaffold.scroll_to(link.target.attr('id'), ActiveScaffold.config.scroll_on_close === 'checkInViewport');
1342
+ }
1343
+ };
1344
+ if (this.position === 'popup') {
1345
+ ActiveScaffold.close_popup(this, callback);
1346
+ } else if (this.adapter) {
1347
+ ActiveScaffold.remove(this.adapter, callback);
1334
1348
  }
1335
1349
  },
1336
1350
 
@@ -1391,7 +1405,7 @@
1391
1405
  if (refresh) l.refresh_url = this.target.closest('.records').data('refresh-record').replace('--ID--', refresh);
1392
1406
 
1393
1407
  if (l.position) {
1394
- l.url = l.url.append_params({adapter: '_list_inline_adapter'});
1408
+ l.url = l.url.append_params({adapter: l.position == 'popup' ? '_popup_adapter' : '_list_inline_adapter'});
1395
1409
  l.tag.attr('href', l.url);
1396
1410
  }
1397
1411
  l.set = this;
@@ -1412,9 +1426,13 @@
1412
1426
  insert: function(content) {
1413
1427
  this.close_previous_adapter();
1414
1428
 
1415
- if (this.position == 'replace') {
1429
+ if (this.position === 'replace') {
1416
1430
  this.position = 'after';
1417
1431
  this.hide_target = true;
1432
+ } else if (this.position === 'table') {
1433
+ this.hide_content = true;
1434
+ } else if (this.position === 'popup') {
1435
+ return ActiveScaffold.open_popup(content, this);
1418
1436
  }
1419
1437
 
1420
1438
  var colspan = this.target.children().length;
@@ -1422,15 +1440,17 @@
1422
1440
  content = jQuery(content);
1423
1441
  content.find('.inline-adapter-cell:first').attr('colspan', colspan);
1424
1442
  }
1425
- if (this.position == 'after') {
1443
+ if (this.position === 'after') {
1426
1444
  this.target.after(content);
1427
1445
  this.set_adapter(this.target.next());
1428
- }
1429
- else if (this.position == 'before') {
1446
+ } else if (this.position === 'before') {
1430
1447
  this.target.before(content);
1431
1448
  this.set_adapter(this.target.prev());
1432
- }
1433
- else {
1449
+ } else if (this.position === 'table') {
1450
+ var content_parent = this.target.closest('div.active-scaffold').find('tbody.before-header').first()
1451
+ content_parent.prepend(content);
1452
+ this.set_adapter(content_parent.children().first())
1453
+ } else {
1434
1454
  return false;
1435
1455
  }
1436
1456
  ActiveScaffold.highlight(this.adapter.find('td'));
@@ -1468,10 +1488,10 @@
1468
1488
  },
1469
1489
 
1470
1490
  set_opened: function() {
1471
- if (this.position == 'after') {
1491
+ if (this.position === 'after') {
1472
1492
  this.set_adapter(this.target.next());
1473
1493
  }
1474
- else if (this.position == 'before') {
1494
+ else if (this.position === 'before') {
1475
1495
  this.set_adapter(this.target.prev());
1476
1496
  }
1477
1497
  this.disable();
@@ -1497,13 +1517,14 @@
1497
1517
  if (this.position == 'replace') {
1498
1518
  this.position = 'top';
1499
1519
  this.hide_content = true;
1520
+ } else if (this.position == 'popup') {
1521
+ return ActiveScaffold.open_popup(content, this);
1500
1522
  }
1501
1523
 
1502
1524
  if (this.position == 'top') {
1503
1525
  this.target.prepend(content);
1504
1526
  this.set_adapter(this.target.children().first());
1505
- }
1506
- else {
1527
+ } else {
1507
1528
  throw 'Unknown position "' + this.position + '"'
1508
1529
  }
1509
1530
  ActiveScaffold.highlight(this.adapter.find('td').first().children().not('script'));
@@ -110,6 +110,9 @@ color: $column_color;
110
110
  color: $header_color;
111
111
  }
112
112
 
113
+ .active-scaffold div.actions a.separator {
114
+ border-color: $action_group_border_color;
115
+ }
113
116
  .active-scaffold-header div.actions a.disabled {
114
117
  color: $actions_disabled_color;
115
118
  }
@@ -191,6 +194,10 @@ color: $column_empty_color;
191
194
  border-color: $column_actions_border_color;
192
195
  }
193
196
 
197
+ .active-scaffold tr.record td.actions table td.separator {
198
+ border-color: $column_actions_border_color;
199
+ }
200
+
194
201
  .active-scaffold tr.record td.actions a.disabled {
195
202
  color: $actions_disabled_color;
196
203
  }
@@ -110,6 +110,12 @@ top: 14px;
110
110
  top: -3px;
111
111
  }
112
112
 
113
+ .active-scaffold div.actions a.separator {
114
+ border-right: 1px solid;
115
+ padding-right: 0;
116
+ padding-left: 0;
117
+ }
118
+
113
119
  .active-scaffold div.actions a.disabled {
114
120
  opacity: 0.5;
115
121
  }
@@ -251,6 +257,11 @@ text-align: right;
251
257
  padding: 0 2px;
252
258
  }
253
259
 
260
+ .active-scaffold tr.record td.actions table td.separator {
261
+ border-right: solid 1px;
262
+ padding: 0;
263
+ }
264
+
254
265
  .active-scaffold tr.record td.actions a,
255
266
  .active-scaffold tr.record td.actions div {
256
267
  font-weight: bold;
@@ -304,6 +315,16 @@ width: auto;
304
315
  text-align: left;
305
316
  }
306
317
 
318
+ .active-scaffold .actions .action_group ul li.separator {
319
+ border-top-width: 1px;
320
+ border-top-style: solid;
321
+ height: 0;
322
+ }
323
+
324
+ .active-scaffold .actions .action_group ul li.separator + li {
325
+ border-top: none;
326
+ }
327
+
307
328
  .active-scaffold .actions .action_group ul li div {
308
329
  margin: 0;
309
330
  padding: 5px 5px 5px 25px;
@@ -476,6 +497,12 @@ padding: 4px;
476
497
  text-align: center;
477
498
  position: relative;
478
499
  }
500
+ .active-scaffold .filtered-message {
501
+ display: flex;
502
+ }
503
+ .active-scaffold .filtered-message > * {
504
+ flex-grow: 1;
505
+ }
479
506
 
480
507
  .active-scaffold .message, .active-scaffold-component .message {
481
508
  font-size: 11px;
@@ -491,10 +518,9 @@ display: inline;
491
518
  }
492
519
 
493
520
  .active-scaffold .filtered-message .reset {
494
- position: absolute;
495
- display: inline;
496
- right: 10px;
497
- top: 4px;
521
+ margin-right: 5px;
522
+ white-space: nowrap;
523
+ flex-grow: 0;
498
524
  padding: 0;
499
525
  }
500
526
 
@@ -3,14 +3,7 @@
3
3
  <tbody>
4
4
  <tr>
5
5
  <td class="messages-container">
6
- <p class="error-message message server-error" style="display:none;">
7
- <%= as_(:internal_error).html_safe %>
8
- <span class="error-500"><%= as_(:error_500).html_safe %></span>
9
- <a href="#" class="close" title="<%= as_(:close).html_safe %>"><%= as_(:close).html_safe %></a>
10
- </p>
11
- <div id="<%= active_scaffold_messages_id -%>" class="action-messages">
12
- <%= render :partial => 'messages' %>
13
- </div>
6
+ <%= render 'list_messages_content' %>
14
7
  </td>
15
8
  </tr>
16
9
  </tbody>
@@ -26,7 +19,7 @@
26
19
  <%= render :partial => 'list_messages', :locals => {:columns => columns} %>
27
20
  <tbody class="records" id="<%= active_scaffold_tbody_id %>" data-refresh-record="<%= url_for(params_for(:action => :index, :id => '--ID--')) %>">
28
21
  <% if !@page.empty? -%>
29
- <%= render :partial => 'list_record', :collection => @page.items, :locals => {:hidden => false, :columns => columns, :action_links => active_scaffold_config.action_links.member} %>
22
+ <%= render :partial => list_record_view, :collection => @page.items, :locals => {:hidden => false, :columns => columns, :action_links => active_scaffold_config.action_links.member} %>
30
23
  <% end -%>
31
24
  </tbody>
32
25
  <% if columns.any? {|c| c.calculation?} -%>
@@ -1,12 +1,23 @@
1
1
  <%# nested_id, allows us to remove a nested scaffold programmatically %>
2
- <tr class="inline-adapter" id="<%= element_row_id :action => :nested %>">
2
+ <tr class="inline-adapter" id="<%= nested_id = element_row_id action: :nested %>">
3
3
  <td class="inline-adapter-cell">
4
4
  <% if successful? %>
5
5
  <div class="<%= "#{params[:action]}-view" if params[:action] %> <%= "#{nested? ? nested.name : id_from_controller(params[:controller])}-view" %> view">
6
- <%= link_to(as_(:close), '', :class => 'inline-adapter-close as_cancel', :remote => true, :title => as_(:close)) -%>
6
+ <%= link_to(as_(:close), '', class: 'inline-adapter-close as_cancel', remote: true, title: as_(:close)) -%>
7
7
  <%= payload -%>
8
8
  </div>
9
9
  <% end %>
10
- <%= javascript_tag("setTimeout(function() { 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)}');#{' action_link.close(); ActiveScaffold.scroll_to(action_link.scaffold(), ActiveScaffold.config.scroll_on_close == "checkInViewport");' unless successful?} } }, 10);") %>
10
+ <%= javascript_tag do %>
11
+ setTimeout(function() {
12
+ var action_link = ActiveScaffold.ActionLink.get('<%= nested_id %>');
13
+ if (action_link) {
14
+ action_link.update_flash_messages('<%= escape_javascript(render('messages').strip) %>');
15
+ <% unless successful? %>
16
+ action_link.close();
17
+ ActiveScaffold.scroll_to(action_link.scaffold(), ActiveScaffold.config.scroll_on_close == "checkInViewport");
18
+ <% end %>
19
+ }
20
+ }, 10);
21
+ <% end %>
11
22
  </td>
12
23
  </tr>
@@ -2,20 +2,11 @@
2
2
  <tbody class="messages">
3
3
  <tr class="record even-record">
4
4
  <td colspan="<%= column_count -%>" class="messages-container">
5
- <% unless active_scaffold_config.list.messages_above_header %>
6
- <p class="error-message message server-error" style="display:none;">
7
- <%= as_(:internal_error).html_safe %>
8
- <span class="error-500"><%= as_(:error_500).html_safe %></span>
9
- <a href="#" class="close" title="<%= as_(:close).html_safe %>"><%= as_(:close).html_safe %></a>
10
- </p>
11
- <div id="<%= active_scaffold_messages_id -%>" class="action-messages">
12
- <%= render :partial => 'messages' %>
13
- </div>
14
- <% end %>
5
+ <%= render 'list_messages_content' unless active_scaffold_config.list.messages_above_header %>
15
6
  <%= content_tag :div, class: 'filtered-message',
16
7
  style: ('display:none;' unless @filtered),
17
8
  data: ({search: search_params || ''} if active_scaffold_config.store_user_settings && respond_to?(:search_params)) do %>
18
- <%= @filtered.is_a?(Array) ? render(:partial => 'human_conditions', :locals => {:columns => @filtered}) : as_(active_scaffold_config.list.filtered_message) %>
9
+ <div><%= @filtered.is_a?(Array) ? render(:partial => 'human_conditions', :locals => {:columns => @filtered}) : as_(active_scaffold_config.list.filtered_message) %></div>
19
10
  <% if active_scaffold_config.list.show_search_reset && @filtered -%>
20
11
  <div class="reset">
21
12
  <%= loading_indicator_tag(:action => :record, :id => nil) %>
@@ -0,0 +1,8 @@
1
+ <p class="error-message message server-error" style="display:none;">
2
+ <%= as_(:internal_error).html_safe %>
3
+ <span class="error-500"><%= as_(:error_500).html_safe %></span>
4
+ <a href="#" class="close" title="<%= as_(:close).html_safe %>"><%= as_(:close).html_safe %></a>
5
+ </p>
6
+ <div id="<%= active_scaffold_messages_id -%>" class="action-messages">
7
+ <%= render 'messages' %>
8
+ </div>
@@ -9,7 +9,7 @@
9
9
  <% elsif active_scaffold_config.create.refresh_list %>
10
10
  <%= render 'refresh_list', no_history: true %>
11
11
  <% elsif params[:parent_controller].nil? %>
12
- <% new_row = render 'list_record', record: @saved_record || @record %>
12
+ <% new_row = render list_record_view, record: @saved_record || @record %>
13
13
  ActiveScaffold.create_record_row(action_link ? action_link.scaffold() : '<%= active_scaffold_id %>', '<%= escape_javascript(new_row) %>', <%= {insert_at: insert_at}.to_json.html_safe %>);
14
14
  <%= render 'update_calculations' %>
15
15
  <% end %>
@@ -0,0 +1,20 @@
1
+ <%# nested_id, allows us to remove a nested scaffold programmatically %>
2
+ <div class="active-scaffold" id="<%= nested_id = element_row_id action: :nested %>">
3
+ <% if successful? %>
4
+ <div class="<%= "#{params[:action]}-view" if params[:action] %> <%= "#{nested? ? nested.name : id_from_controller(params[:controller])}-view" %> view">
5
+ <%= payload -%>
6
+ </div>
7
+ <% end %>
8
+ <%= javascript_tag do %>
9
+ setTimeout(function() {
10
+ var action_link = ActiveScaffold.ActionLink.get('<%= nested_id %>');
11
+ if (action_link) {
12
+ action_link.update_flash_messages('<%= escape_javascript(render('messages').strip) %>');
13
+ <% unless successful? %>
14
+ action_link.close();
15
+ ActiveScaffold.scroll_to(action_link.scaffold(), ActiveScaffold.config.scroll_on_close == "checkInViewport");
16
+ <% end %>
17
+ }
18
+ }, 10);
19
+ <% end %>
20
+ </div>
@@ -1,6 +1,6 @@
1
1
  <% if @auto_pagination -%>
2
2
  <% if @page.items.present? -%>
3
- ActiveScaffold.append('<%= active_scaffold_tbody_id %>', '<%= escape_javascript(render(:partial => 'list_record', :collection => @page.items, :locals => {:hidden => false, :columns => list_columns, :action_links => active_scaffold_config.action_links.member})) %>');
3
+ ActiveScaffold.append('<%= active_scaffold_tbody_id %>', '<%= escape_javascript(render(:partial => list_record_view, :collection => @page.items, :locals => {:hidden => false, :columns => list_columns, :action_links => active_scaffold_config.action_links.member})) %>');
4
4
 
5
5
  <% if @page.pager.infinite? || @page.number < @page.pager.number_of_pages -%>
6
6
  ActiveScaffold.auto_load_page('<%= url_for main_path_to_return %>', {auto_pagination: true, page: <%= @page.number + 1 %>});
@@ -1 +1 @@
1
- <%= render :partial => 'list_record', :locals => {:record => record} %>
1
+ <%= render :partial => list_record_view, :locals => {:record => record} %>
@@ -1,4 +1,4 @@
1
- <% new_row = render :partial => 'list_record', :locals => {:record => @record} %>
1
+ <% new_row = render :partial => list_record_view, :locals => {:record => @record} %>
2
2
  ActiveScaffold.create_record_row('<%= active_scaffold_id %>', '<%= escape_javascript(new_row) %>', <%= {:insert_at => :top}.to_json.html_safe %>);
3
3
 
4
4
  <%= render :partial => 'update_calculations', :formats => [:js] %>
@@ -5,7 +5,7 @@ link = ActiveScaffold.find_action_link('<%= element_form_id(:action => action_na
5
5
  <% if successful? %>
6
6
  <% if @record %>
7
7
  <%= render :partial => 'update_messages' %>
8
- <% row = escape_javascript(render(:partial => 'list_record', :locals => {:record => @record})) -%>
8
+ <% row = escape_javascript(render(:partial => list_record_view, :locals => {:record => @record})) -%>
9
9
  <% if @action_link&.position %>
10
10
  if (link) link.close('<%= row %>');
11
11
  <% else %>
@@ -5,7 +5,7 @@ if (action_link) action_link.update_flash_messages('<%= escape_javascript(render
5
5
  <% if successful? %>
6
6
  <% if params[:dont_close] %>
7
7
  <% row_selector = element_row_id(:action => :list, :id => @record.id) %>
8
- ActiveScaffold.update_row('<%= row_selector %>', '<%= escape_javascript(render(:partial => 'list_record', :locals => {:record => @record})) %>');
8
+ ActiveScaffold.update_row('<%= row_selector %>', '<%= escape_javascript(render(:partial => list_record_view, :locals => {:record => @record})) %>');
9
9
  if (action_link) action_link.target = $('#<%= row_selector %>');
10
10
  <%= render :partial => 'update_calculations', :formats => [:js] %>
11
11
  <% if params[:iframe] == 'true' %>
@@ -22,7 +22,7 @@ if (action_link) action_link.update_flash_messages('<%= escape_javascript(render
22
22
  <%= render 'refresh_list', no_history: true %>
23
23
  <% else %>
24
24
  <% if @record %>
25
- if (action_link) action_link.close('<%= escape_javascript(render(:partial => 'list_record', :locals => {:record => @record})) %>');
25
+ if (action_link) action_link.close('<%= escape_javascript(render(:partial => list_record_view, :locals => {:record => @record})) %>');
26
26
  <% else %>
27
27
  if (action_link) action_link.close();
28
28
  ActiveScaffold.delete_record_row('<%= element_row_id(:action => :list, :id => params[:id]) %>');
@@ -1,2 +1,2 @@
1
- ActiveScaffold.update_row('<%= element_row_id(action: :list, id: @record&.id) %>', '<%= escape_javascript render('list_record', record: @record) %>');
1
+ ActiveScaffold.update_row('<%= element_row_id(action: :list, id: @record&.id) %>', '<%= escape_javascript render(list_record_view, record: @record) %>');
2
2
  <%= render :partial => 'update_calculations', :formats => [:js] %>
@@ -1 +1 @@
1
- ActiveScaffold.update_row('<%=element_row_id(:action => 'list', :id => @record.id)%>','<%=escape_javascript(render(:partial => 'list_record', :locals => {:record => @record}))%>');
1
+ ActiveScaffold.update_row('<%=element_row_id(:action => 'list', :id => @record.id)%>','<%=escape_javascript(render(:partial => list_record_view, :locals => {:record => @record}))%>');
@@ -182,12 +182,15 @@ module ActiveScaffold::DataStructures
182
182
  # where the result of this action should insert in the display.
183
183
  # for :type => :collection, supported values are:
184
184
  # :top
185
- # :replace (for updating the entire table)
185
+ # :replace (to hide the entire table)
186
+ # :popup (popup with JS library)
186
187
  # false (no attempt at positioning)
187
188
  # for :type => :member, supported values are:
188
189
  # :before
189
- # :replace
190
+ # :replace (to hide the record row)
190
191
  # :after
192
+ # :table (to hide the entire table)
193
+ # :popup (popup with JS library)
191
194
  # false (no attempt at positioning)
192
195
  attr_writer :position
193
196
  def position
@@ -0,0 +1,13 @@
1
+ class ActionLinkSeparator
2
+ def initialize(weight)
3
+ @weight = weight
4
+ end
5
+
6
+ attr_reader :weight
7
+
8
+ def ==(other)
9
+ other == :separator
10
+ end
11
+
12
+ def name_to_cache; end # :nodoc:
13
+ end
@@ -34,6 +34,12 @@ module ActiveScaffold::DataStructures
34
34
  end
35
35
  alias << add
36
36
 
37
+ def add_separator(weight = 0)
38
+ raise 'Call add_separator on a group' if name == :root
39
+
40
+ add_to_set ActionLinkSeparator.new(weight)
41
+ end
42
+
37
43
  def add_to_set(link)
38
44
  @set << link
39
45
  end
@@ -51,6 +57,8 @@ module ActiveScaffold::DataStructures
51
57
  def [](val)
52
58
  links = []
53
59
  @set.each do |item|
60
+ next if item == :separator
61
+
54
62
  if item.is_a?(ActiveScaffold::DataStructures::ActionLinks)
55
63
  collected = item[val]
56
64
  links << collected unless collected.nil?
@@ -64,6 +72,8 @@ module ActiveScaffold::DataStructures
64
72
  def find_duplicate(link)
65
73
  links = []
66
74
  @set.each do |item|
75
+ next if item == :separator
76
+
67
77
  if item.is_a?(ActiveScaffold::DataStructures::ActionLinks)
68
78
  collected = item.find_duplicate(link)
69
79
  links << collected unless collected.nil?
@@ -75,7 +85,9 @@ module ActiveScaffold::DataStructures
75
85
  end
76
86
 
77
87
  def delete(val)
78
- each(:include_set => true) do |link, set|
88
+ each(include_set: true) do |link, set|
89
+ next if link == :separator
90
+
79
91
  if link.action.to_s == val.to_s
80
92
  set.delete link
81
93
  break
@@ -109,12 +121,6 @@ module ActiveScaffold::DataStructures
109
121
  end
110
122
  end
111
123
 
112
- def collect_by_type(type = nil)
113
- links = []
114
- subgroup(type).each(type) { |link| links << link }
115
- links
116
- end
117
-
118
124
  def collect
119
125
  @set
120
126
  end
@@ -171,9 +177,9 @@ module ActiveScaffold::DataStructures
171
177
  attr_accessor :css_class
172
178
 
173
179
  def name=(value)
174
- ActiveSupport::Deprecation.warn 'Changing name is deprecated, use css_class to change the class html attribute'
175
180
  self.css_class = value
176
181
  end
182
+ ActiveScaffold.deprecator.deprecate_methods(self, :name= => :css_class=)
177
183
 
178
184
  protected
179
185
 
@@ -35,32 +35,49 @@ module ActiveScaffold
35
35
  options[:level] ||= 0
36
36
  options[:first_action] = true
37
37
  output = ActiveSupport::SafeBuffer.new
38
+ prev_link = separator = nil
38
39
 
39
- action_links.each(:reverse => options.delete(:reverse), :groups => true) do |link|
40
+ action_links.each(reverse: options.delete(:reverse), groups: true) do |link|
41
+ if link == :separator
42
+ separator = true if prev_link
43
+ next
44
+ end
45
+ content = nil
40
46
  if link.is_a? ActiveScaffold::DataStructures::ActionLinks
41
- unless link.empty?
42
- options[:level] += 1
43
- content = display_action_links(link, record, options, &block)
44
- options[:level] -= 1
45
- if content.present?
46
- output << display_action_link(link, content, record, options)
47
- options[:first_action] = false
48
- end
49
- end
47
+ content = display_action_link_group(link, record, options, &block) unless link.empty?
50
48
  elsif !skip_action_link?(link, *Array(options[:for]))
51
49
  authorized, reason = action_link_authorized?(link, *Array(options[:for]))
52
50
  next if !authorized && options[:skip_unauthorized]
53
- output << display_action_link(link, nil, record, options.merge(:authorized => authorized, :not_authorized_reason => reason))
51
+
52
+ content = display_action_link(link, nil, record, options.merge(authorized: authorized, not_authorized_reason: reason))
54
53
  options[:first_action] = false
55
54
  end
55
+ next if content.blank?
56
+
57
+ prev_link = true
58
+ output << display_action_link_separator(options) if separator
59
+ output << content
60
+ separator = false
56
61
  end
57
62
  output
58
63
  end
59
64
 
65
+ def display_action_link_group(link, record, options, &block)
66
+ options[:level] += 1
67
+ content = display_action_links(link, record, options, &block)
68
+ options[:level] -= 1
69
+ display_action_link(link, content, record, options).tap { options[:first_action] = false } if content.present?
70
+ end
71
+
72
+ def display_action_link_separator(options)
73
+ tag = options[:level_0_tag] || :a if options[:level].zero?
74
+ content_tag(tag || :li, '&nbsp;'.html_safe, class: 'separator') # rubocop:disable Rails/OutputSafety
75
+ end
76
+
60
77
  def display_action_link(link, content, record, options)
61
78
  if content
62
79
  html_classes = hover_via_click? ? 'hover_click ' : ''
63
- if (options[:level]).zero?
80
+ if options[:level].zero?
64
81
  html_classes << 'action_group'
65
82
  group_tag = :div
66
83
  else
@@ -72,9 +89,9 @@ module ActiveScaffold
72
89
  end
73
90
  else
74
91
  content = render_action_link(link, record, options)
75
- content = content_tag(:li, content, :class => ('top' if options[:first_action])) unless (options[:level]).zero?
92
+ content = content_tag(:li, content, class: ('top' if options[:first_action])) unless options[:level].zero?
76
93
  end
77
- content = content_tag(options[:level_0_tag], content, options[:options_level_0_tag]) if (options[:level]).zero? && options[:level_0_tag]
94
+ content = content_tag(options[:level_0_tag], content, options[:options_level_0_tag]) if options[:level].zero? && options[:level_0_tag]
78
95
  content
79
96
  end
80
97
 
@@ -23,7 +23,7 @@ module ActiveScaffold
23
23
  end
24
24
 
25
25
  def format_human_condition(column, opt, from = nil, to = nil)
26
- attribute = column.active_record_class.human_attribute_name(column.name)
26
+ attribute = column.label
27
27
  opt ||= :between if from && to
28
28
  opt ||= from ? '>=' : '<='
29
29
  from = to = nil if opt&.in? %w[null not_null]
@@ -51,15 +51,15 @@ module ActiveScaffold
51
51
  range_type, range = value['range'].downcase.split('_')
52
52
  format = active_scaffold_human_condition_datetime_range_format(range_type, range)
53
53
  from, = controller.class.datetime_from_to(column, value)
54
- "#{column.active_record_class.human_attribute_name(column.name)} = #{as_(value['range'].downcase).downcase} (#{I18n.l(from, :format => format)})"
55
- when 'PAST', 'FUTURE'
54
+ "#{column.label} = #{as_(value['range'].downcase).downcase} (#{I18n.l(from, :format => format)})"
55
+ when 'PAST', 'FUTURE', 'BETWEEN'
56
56
  from, to = controller.class.datetime_from_to(column, value)
57
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_('BETWEEN'.downcase).downcase} #{I18n.l(from)} - #{I18n.l(to)}"
57
+ "#{column.label} #{as_('between').downcase} #{I18n.l(from)} - #{I18n.l(to)}"
58
58
  when 'null', 'not_null'
59
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_(value['opt'].downcase).downcase}"
59
+ "#{column.label} #{as_(value['opt'].downcase).downcase}"
60
60
  else
61
- from, to = controller.class.datetime_from_to(column, value)
62
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_(value['opt'].downcase).downcase} #{I18n.l(from)} #{value['opt'] == 'BETWEEN' ? '- ' + I18n.l(to) : ''}"
61
+ from, = controller.class.datetime_from_to(column, value)
62
+ "#{column.label} #{as_(value['opt'].downcase).downcase} #{I18n.l(from)}"
63
63
  end
64
64
  end
65
65
  alias active_scaffold_human_condition_time active_scaffold_human_condition_datetime
@@ -93,7 +93,7 @@ module ActiveScaffold
93
93
  # end
94
94
 
95
95
  def active_scaffold_human_condition_boolean(column, value)
96
- attribute = column.active_record_class.human_attribute_name(column.name)
96
+ attribute = column.label
97
97
  as_(:boolean, :scope => :human_conditions, :column => attribute, :value => as_(value))
98
98
  end
99
99
  alias active_scaffold_human_condition_checkbox active_scaffold_human_condition_boolean
@@ -103,7 +103,7 @@ module ActiveScaffold
103
103
  end
104
104
 
105
105
  def active_scaffold_human_condition_select(column, associated)
106
- attribute = column.active_record_class.human_attribute_name(column.name)
106
+ attribute = column.label
107
107
  if associated.is_a?(Hash)
108
108
  return active_scaffold_human_condition_range(column, associated) unless associated['opt'] == '='
109
109
  associated = associated['from']
@@ -2,6 +2,10 @@ module ActiveScaffold
2
2
  module Helpers
3
3
  # Helpers that assist with the rendering of a List Column
4
4
  module ListColumnHelpers
5
+ def list_record_view
6
+ 'list_record'
7
+ end
8
+
5
9
  def get_column_value(record, column)
6
10
  record = record.send(column.delegated_association.name) if column.delegated_association
7
11
  if record
@@ -2,8 +2,8 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 7
5
- PATCH = 10
6
- FIX = nil
5
+ PATCH = 11
6
+ FIX = 1
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, FIX].compact.join('.')
9
9
  end
@@ -68,7 +68,7 @@ module ActiveScaffold
68
68
  end
69
69
  when :prototype then warning += ', convert your app to jQuery, and remove this call'
70
70
  end
71
- ActiveSupport::Deprecation.warn warning
71
+ deprecator.warn warning
72
72
  @@js_framework = framework
73
73
  end
74
74
 
@@ -110,6 +110,10 @@ module ActiveScaffold
110
110
  def self.defaults(&block)
111
111
  ActiveScaffold::Config::Core.configure(&block)
112
112
  end
113
+
114
+ def self.deprecator
115
+ @deprecator ||= ActiveSupport::Deprecation.new('4.0', 'ActiveScaffold')
116
+ end
113
117
  end
114
118
  require 'active_scaffold/engine'
115
119
  require 'ice_nine'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.10
4
+ version: 3.7.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Many, see README
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-13 00:00:00.000000000 Z
11
+ date: 2025-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -147,12 +147,14 @@ files:
147
147
  - app/views/active_scaffold_overrides/_list_header.html.erb
148
148
  - app/views/active_scaffold_overrides/_list_inline_adapter.html.erb
149
149
  - app/views/active_scaffold_overrides/_list_messages.html.erb
150
+ - app/views/active_scaffold_overrides/_list_messages_content.html.erb
150
151
  - app/views/active_scaffold_overrides/_list_pagination.html.erb
151
152
  - app/views/active_scaffold_overrides/_list_pagination_links.html.erb
152
153
  - app/views/active_scaffold_overrides/_list_record.html.erb
153
154
  - app/views/active_scaffold_overrides/_list_with_header.html.erb
154
155
  - app/views/active_scaffold_overrides/_messages.html.erb
155
156
  - app/views/active_scaffold_overrides/_new_record.js.erb
157
+ - app/views/active_scaffold_overrides/_popup_adapter.html.erb
156
158
  - app/views/active_scaffold_overrides/_refresh_create_form.js.erb
157
159
  - app/views/active_scaffold_overrides/_refresh_list.js.erb
158
160
  - app/views/active_scaffold_overrides/_render_field.js.erb
@@ -290,6 +292,7 @@ files:
290
292
  - lib/active_scaffold/core.rb
291
293
  - lib/active_scaffold/data_structures/action_columns.rb
292
294
  - lib/active_scaffold/data_structures/action_link.rb
295
+ - lib/active_scaffold/data_structures/action_link_separator.rb
293
296
  - lib/active_scaffold/data_structures/action_links.rb
294
297
  - lib/active_scaffold/data_structures/actions.rb
295
298
  - lib/active_scaffold/data_structures/association.rb