active_scaffold_sortable 3.3.2 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c14dd5e8d58a0208aee3c71b855154a86fb2bba
|
4
|
+
data.tar.gz: 509b37f696c12f5f23a5061e93b26f0aa03c62ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
12
|
-
|
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 =
|
19
|
-
if (style)
|
20
|
-
else
|
21
|
-
|
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(
|
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(
|
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
|
-
|
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(
|
63
|
-
new_order =
|
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
|
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.
|
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-
|
12
|
+
date: 2017-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active_scaffold
|