activeadmin_sortable_table 1.1.0 → 1.1.1
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: ff2920f60aff67fdac3ec70b48d4d5210a835da2
|
4
|
+
data.tar.gz: 262a555140d2385c54f1de47b6cdf841039dffcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 683dc3e1766264211cd93c433444adf5282effc9dede49e752d8a47baab9b6aa53d80a087775d2bfcea3b6545cda538cc5947901db109b6ef68a3d6be90059f9
|
7
|
+
data.tar.gz: d2c833437e3b94461d0843c453b67e61e0cdaa0d03510a4a93b2e04c90edd6f492cfb2511df9189f73ee9282f984ecb302bccbb011eb93672f9f87622c4bd7b2
|
data/Gemfile.lock
CHANGED
@@ -10,18 +10,31 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
context 'first page' do
|
13
|
-
it '
|
13
|
+
it 'reorders elements by dragging vertically by handle', js: true do
|
14
14
|
expect(ordered_elements).to eq([1, 2, 3])
|
15
15
|
|
16
16
|
visit admin_categories_path
|
17
17
|
|
18
18
|
expect(visible_elements).to eq([1, 2, 3])
|
19
19
|
|
20
|
-
move_higher(2)
|
20
|
+
move_higher(2, by_handle: true)
|
21
21
|
|
22
22
|
expect(visible_elements).to eq([2, 1, 3])
|
23
23
|
expect(ordered_elements).to eq([2, 1, 3])
|
24
24
|
end
|
25
|
+
|
26
|
+
it 'does not reorder elements by dragging vertically by row', js: true do
|
27
|
+
expect(ordered_elements).to eq([1, 2, 3])
|
28
|
+
|
29
|
+
visit admin_categories_path
|
30
|
+
|
31
|
+
expect(visible_elements).to eq([1, 2, 3])
|
32
|
+
|
33
|
+
move_higher(2, by_handle: false)
|
34
|
+
|
35
|
+
expect(visible_elements).to eq([1, 2, 3])
|
36
|
+
expect(ordered_elements).to eq([1, 2, 3])
|
37
|
+
end
|
25
38
|
end
|
26
39
|
|
27
40
|
context 'second page' do
|
@@ -31,34 +44,51 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature do
|
|
31
44
|
Category.create!
|
32
45
|
end
|
33
46
|
|
34
|
-
it '
|
47
|
+
it 'reorders elements by dragging vertically by handle', js: true do
|
35
48
|
expect(ordered_elements).to eq([1, 2, 3, 4, 5, 6])
|
36
49
|
|
37
50
|
visit admin_categories_path(page: 2)
|
38
51
|
|
39
52
|
expect(visible_elements).to eq([4, 5, 6])
|
40
53
|
|
41
|
-
move_higher(5)
|
54
|
+
move_higher(5, by_handle: true)
|
42
55
|
|
43
56
|
expect(visible_elements).to eq([5, 4, 6])
|
44
57
|
expect(ordered_elements).to eq([1, 2, 3, 5, 4, 6])
|
45
58
|
end
|
59
|
+
|
60
|
+
it 'does not reorder elements by dragging vertically by row', js: true do
|
61
|
+
expect(ordered_elements).to eq([1, 2, 3, 4, 5, 6])
|
62
|
+
|
63
|
+
visit admin_categories_path(page: 2)
|
64
|
+
|
65
|
+
expect(visible_elements).to eq([4, 5, 6])
|
66
|
+
|
67
|
+
move_higher(5, by_handle: false)
|
68
|
+
|
69
|
+
expect(visible_elements).to eq([4, 5, 6])
|
70
|
+
expect(ordered_elements).to eq([1, 2, 3, 4, 5, 6])
|
71
|
+
end
|
46
72
|
end
|
47
73
|
|
48
74
|
private
|
49
75
|
|
50
76
|
def visible_elements
|
51
|
-
all('.ui-sortable
|
77
|
+
all('.ui-sortable .col-id').map(&:text).map(&:to_i)
|
52
78
|
end
|
53
79
|
|
54
|
-
def move_higher(element_id)
|
55
|
-
drag_element(element_id, dy: -200)
|
80
|
+
def move_higher(element_id, by_handle:)
|
81
|
+
drag_element(element_id, by_handle, dy: -200)
|
56
82
|
end
|
57
83
|
|
58
|
-
def drag_element(element_id, options)
|
59
|
-
|
60
|
-
|
61
|
-
|
84
|
+
def drag_element(element_id, by_handle, options)
|
85
|
+
options.reverse_merge! moves: 20
|
86
|
+
if by_handle
|
87
|
+
wait_for_ajax do
|
88
|
+
page.execute_script(%($("#category_#{element_id} .handle").simulate("drag", #{options.to_json})))
|
89
|
+
end
|
90
|
+
else
|
91
|
+
page.execute_script(%($("#category_#{element_id}").simulate("drag", #{options.to_json})))
|
62
92
|
end
|
63
93
|
end
|
64
94
|
end
|
@@ -36,7 +36,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Move to top', type: :feature do
|
|
36
36
|
private
|
37
37
|
|
38
38
|
def visible_elements
|
39
|
-
all('.ui-sortable
|
39
|
+
all('.ui-sortable .col-id').map(&:text).map(&:to_i)
|
40
40
|
end
|
41
41
|
|
42
42
|
def move_to_top(element_id)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_sortable_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam McCrea
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-10-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activeadmin
|