active_scaffold_sortable 3.3.2 → 3.3.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71221bcdb5596ef2f904f7f596e893535fd524b3
4
- data.tar.gz: a0b611c659f5ac4d9368b34cfdfa72eb5c678710
3
+ metadata.gz: 2c14dd5e8d58a0208aee3c71b855154a86fb2bba
4
+ data.tar.gz: 509b37f696c12f5f23a5061e93b26f0aa03c62ba
5
5
  SHA512:
6
- metadata.gz: af81bd998a18795ad13c48173598aa09a1d228d935cbf13c7aa46a3f042255090867f5dbaabb8b3d8d498e37d6190df7a5a4b2be83e47265403bd614c4f9253a
7
- data.tar.gz: a6c2a3b4c8bf67c1eb31afe18cd490b71b2c7312138d5025b5e86728e6d556a7df8818cde460a458eac5199db7498a9687d26946b169054911c84adcb6346a76
6
+ metadata.gz: f845984504b564a4a3219c6b4dc6d2e9e007106a349be3e827645a105eedd0374168838af8393590ca276433b5fb9c80bee5bf6c94c175da7af987d93cba150c
7
+ data.tar.gz: bad7987f3ab945c25861545aa1187ea9faff0593de93cb2c8c2a8b8352b897b3757a26efbd13d2d5b1b6ce9a1cebe99f77e68c576a0d0d63b1c6a365957ba2c6
@@ -8,17 +8,17 @@ ActiveScaffold.update_positions = function(content) {
8
8
  ActiveScaffold.sortable = function(element) {
9
9
  var fixHelper = function(e, ui) {
10
10
  ui.find('*').each(function() {
11
- $(this).data('sortable-prev-style', $(this).attr('style'));
12
- $(this).width($(this).width());
11
+ jQuery(this).data('sortable-prev-style', jQuery(this).attr('style'));
12
+ jQuery(this).width(jQuery(this).width());
13
13
  });
14
14
  return ui;
15
15
  };
16
16
  var restoreHelper = function(e, ui) {
17
17
  ui.helper.find('*').each(function() {
18
- var style = $(this).data('sortable-prev-style');
19
- if (style) $(this).attr('style', style);
20
- else $(this).removeAttr('style');
21
- $(this).removeData('sortable-prev-style');
18
+ var style = jQuery(this).data('sortable-prev-style');
19
+ if (style) jQuery(this).attr('style', style);
20
+ else jQuery(this).removeAttr('style');
21
+ jQuery(this).removeData('sortable-prev-style');
22
22
  });
23
23
  };
24
24
  var form, content, sortable_options = {containment: 'parent', tolerance: 'pointer', forcePlaceholderSize: true, placeholder: 'sortable-highlight', helper: fixHelper, beforeStop: restoreHelper};
@@ -42,10 +42,10 @@ module ActiveScaffold::Actions
42
42
  end
43
43
 
44
44
  def reorder_ancestry_tree(model)
45
- first_record = model.find(params[active_scaffold_tbody_id].first)
45
+ first_record = model.find(ordered_ids.first)
46
46
  unless first_record.nil?
47
47
  records = first_record.is_root? ? model.roots: first_record.parent.children
48
- reorder_simple_list(model)
48
+ reorder_simple_list(records)
49
49
  else
50
50
  Rails.logger.info("Failed to find first record to reorder")
51
51
  end
@@ -53,14 +53,14 @@ module ActiveScaffold::Actions
53
53
 
54
54
  def reorder_simple_list(model)
55
55
  column_name = active_scaffold_config.sortable.column.name
56
- params[active_scaffold_tbody_id].each_with_index do |id, index|
56
+ ordered_ids.each.with_index do |id, index|
57
57
  model.where(model.primary_key => id).update_all(column_name => index + 1)
58
58
  end
59
59
  end
60
60
 
61
61
  def reorder_children_in_tree(model)
62
- full_order = model.find(params[active_scaffold_tbody_id].first).try(:self_and_siblings)
63
- new_order = params[active_scaffold_tbody_id].collect {|item_id| item_id.to_i}
62
+ full_order = model.find(ordered_ids.first).try(:self_and_siblings)
63
+ new_order = ordered_ids.collect {|item_id| item_id.to_i}
64
64
  current_order = full_order.length == new_order.length ? full_order : full_order.select{ |r| new_order.include? r.id }
65
65
 
66
66
  new_order.each_with_index do |record_id, new_position|
@@ -78,5 +78,9 @@ module ActiveScaffold::Actions
78
78
  child.self_and_siblings
79
79
  end
80
80
 
81
+ def ordered_ids
82
+ @ordered_ids ||= params.delete active_scaffold_tbody_id
83
+ end
84
+
81
85
  end
82
86
  end
@@ -2,7 +2,7 @@ module ActiveScaffoldSortable
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 3
5
- PATCH = 2
5
+ PATCH = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_sortable
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Cambra
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-06-15 00:00:00.000000000 Z
12
+ date: 2017-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_scaffold