activeadmin_sortable_table 1.1.3 → 1.2.0
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +3 -3
- data/lib/active_admin/sortable_table/handle_column.rb +1 -1
- data/lib/active_admin/sortable_table/version.rb +1 -1
- data/spec/dummy/app/admin/categories.rb +3 -3
- data/spec/dummy/app/models/category.rb +1 -1
- data/spec/dummy/db/migrate/20150910072505_create_categories.rb +1 -1
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/features/drag_and_drop_spec.rb +16 -16
- data/spec/features/move_to_top_spec.rb +5 -5
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bad6787846d549ac47bef5f8c6b56431f5bef5dd
|
|
4
|
+
data.tar.gz: c8c9be5b01fd966f8807f2c5645157100050f698
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca386a268b779c503a074f5c3e1eee2da272b342c4716628ae7b957c1a5ed8f742434b14454ed87d986c0465f7c929e2c7abea1e364accb1fbb3f97eea4e1185
|
|
7
|
+
data.tar.gz: b5ae41b61014415bdb5fb47619901a6429b19a4b19a805f4c86c35982950e5eab3f0904b72a6ac7865ad693deb6f7469e63d8545c2b1d6c251572326b3ff88fc
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -19,7 +19,7 @@ GIT
|
|
|
19
19
|
PATH
|
|
20
20
|
remote: .
|
|
21
21
|
specs:
|
|
22
|
-
activeadmin_sortable_table (1.
|
|
22
|
+
activeadmin_sortable_table (1.2.0)
|
|
23
23
|
activeadmin (>= 1.0.0.pre1)
|
|
24
24
|
uber (= 0.0.15)
|
|
25
25
|
|
|
@@ -130,7 +130,7 @@ GEM
|
|
|
130
130
|
mini_portile (~> 0.6.0)
|
|
131
131
|
parser (2.2.2.6)
|
|
132
132
|
ast (>= 1.1, < 3.0)
|
|
133
|
-
phantomjs (1.
|
|
133
|
+
phantomjs (2.1.1.0)
|
|
134
134
|
poltergeist (1.6.0)
|
|
135
135
|
capybara (~> 2.1)
|
|
136
136
|
cliver (~> 0.3.1)
|
|
@@ -244,4 +244,4 @@ DEPENDENCIES
|
|
|
244
244
|
sqlite3
|
|
245
245
|
|
|
246
246
|
BUNDLED WITH
|
|
247
|
-
1.
|
|
247
|
+
1.14.3
|
|
@@ -38,7 +38,7 @@ module ActiveAdmin
|
|
|
38
38
|
column '', class: 'activeadmin_sortable_table' do |resource|
|
|
39
39
|
options = defined_options.evaluate(self, resource)
|
|
40
40
|
|
|
41
|
-
sort_handle(options, resource.
|
|
41
|
+
sort_handle(options, resource.send(resource.position_column)) + move_to_top_handle(options)
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
ActiveAdmin.register Category do
|
|
2
2
|
include ActiveAdmin::SortableTable
|
|
3
|
-
permit_params :id, :
|
|
4
|
-
config.sort_order = '
|
|
3
|
+
permit_params :id, :number
|
|
4
|
+
config.sort_order = 'number_asc'
|
|
5
5
|
config.per_page = 3
|
|
6
6
|
|
|
7
7
|
index do
|
|
8
8
|
handle_column
|
|
9
9
|
id_column
|
|
10
|
-
column :
|
|
10
|
+
column :number
|
|
11
11
|
actions
|
|
12
12
|
end
|
|
13
13
|
end
|
data/spec/dummy/db/schema.rb
CHANGED
|
@@ -6,7 +6,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def ordered_ids
|
|
9
|
-
Category.order(:
|
|
9
|
+
Category.order(:number).pluck(:id)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
context 'first page' do
|
|
@@ -16,15 +16,15 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
16
16
|
visit admin_categories_path
|
|
17
17
|
|
|
18
18
|
expect(visible_ids).to eq([1, 2, 3])
|
|
19
|
-
expect(
|
|
19
|
+
expect(visible_numbers).to eq([1, 2, 3])
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
context 'move element up' do
|
|
23
|
-
it 'to the top
|
|
23
|
+
it 'to the top number' do
|
|
24
24
|
move_up(3, by: 2)
|
|
25
25
|
|
|
26
26
|
expect(visible_ids).to eq([3, 1, 2])
|
|
27
|
-
expect(
|
|
27
|
+
expect(visible_numbers).to eq([1, 2, 3])
|
|
28
28
|
expect(ordered_ids).to eq([3, 1, 2])
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -32,7 +32,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
32
32
|
move_up(3, by: 1)
|
|
33
33
|
|
|
34
34
|
expect(visible_ids).to eq([1, 3, 2])
|
|
35
|
-
expect(
|
|
35
|
+
expect(visible_numbers).to eq([1, 2, 3])
|
|
36
36
|
expect(ordered_ids).to eq([1, 3, 2])
|
|
37
37
|
end
|
|
38
38
|
end
|
|
@@ -42,7 +42,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
42
42
|
move_down(1, by: 2)
|
|
43
43
|
|
|
44
44
|
expect(visible_ids).to eq([2, 3, 1])
|
|
45
|
-
expect(
|
|
45
|
+
expect(visible_numbers).to eq([1, 2, 3])
|
|
46
46
|
expect(ordered_ids).to eq([2, 3, 1])
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -50,7 +50,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
50
50
|
move_down(2, by: 1)
|
|
51
51
|
|
|
52
52
|
expect(visible_ids).to eq([1, 3, 2])
|
|
53
|
-
expect(
|
|
53
|
+
expect(visible_numbers).to eq([1, 2, 3])
|
|
54
54
|
expect(ordered_ids).to eq([1, 3, 2])
|
|
55
55
|
end
|
|
56
56
|
end
|
|
@@ -59,7 +59,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
59
59
|
move_up(3, by: 2, use_handle: false)
|
|
60
60
|
|
|
61
61
|
expect(visible_ids).to eq([1, 2, 3])
|
|
62
|
-
expect(
|
|
62
|
+
expect(visible_numbers).to eq([1, 2, 3])
|
|
63
63
|
expect(ordered_ids).to eq([1, 2, 3])
|
|
64
64
|
end
|
|
65
65
|
end
|
|
@@ -77,7 +77,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
77
77
|
visit admin_categories_path(page: 2)
|
|
78
78
|
|
|
79
79
|
expect(visible_ids).to eq([4, 5, 6])
|
|
80
|
-
expect(
|
|
80
|
+
expect(visible_numbers).to eq([4, 5, 6])
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
context 'move element up' do
|
|
@@ -85,7 +85,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
85
85
|
move_up(6, by: 2)
|
|
86
86
|
|
|
87
87
|
expect(visible_ids).to eq([6, 4, 5])
|
|
88
|
-
expect(
|
|
88
|
+
expect(visible_numbers).to eq([4, 5, 6])
|
|
89
89
|
expect(ordered_ids).to eq([1, 2, 3, 6, 4, 5])
|
|
90
90
|
end
|
|
91
91
|
|
|
@@ -93,7 +93,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
93
93
|
move_up(6, by: 1)
|
|
94
94
|
|
|
95
95
|
expect(visible_ids).to eq([4, 6, 5])
|
|
96
|
-
expect(
|
|
96
|
+
expect(visible_numbers).to eq([4, 5, 6])
|
|
97
97
|
expect(ordered_ids).to eq([1, 2, 3, 4, 6, 5])
|
|
98
98
|
end
|
|
99
99
|
end
|
|
@@ -103,7 +103,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
103
103
|
move_down(4, by: 2)
|
|
104
104
|
|
|
105
105
|
expect(visible_ids).to eq([5, 6, 4])
|
|
106
|
-
expect(
|
|
106
|
+
expect(visible_numbers).to eq([4, 5, 6])
|
|
107
107
|
expect(ordered_ids).to eq([1, 2, 3, 5, 6, 4])
|
|
108
108
|
end
|
|
109
109
|
|
|
@@ -111,7 +111,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
111
111
|
move_down(4, by: 1)
|
|
112
112
|
|
|
113
113
|
expect(visible_ids).to eq([5, 4, 6])
|
|
114
|
-
expect(
|
|
114
|
+
expect(visible_numbers).to eq([4, 5, 6])
|
|
115
115
|
expect(ordered_ids).to eq([1, 2, 3, 5, 4, 6])
|
|
116
116
|
end
|
|
117
117
|
end
|
|
@@ -120,7 +120,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
120
120
|
move_down(6, by: 2, use_handle: false)
|
|
121
121
|
|
|
122
122
|
expect(visible_ids).to eq([4, 5, 6])
|
|
123
|
-
expect(
|
|
123
|
+
expect(visible_numbers).to eq([4, 5, 6])
|
|
124
124
|
expect(ordered_ids).to eq([1, 2, 3, 4, 5, 6])
|
|
125
125
|
end
|
|
126
126
|
end
|
|
@@ -131,8 +131,8 @@ RSpec.describe ActiveAdmin::SortableTable, 'Drag-and-Drop', type: :feature, js:
|
|
|
131
131
|
all('.ui-sortable .col-id').map(&:text).map(&:to_i)
|
|
132
132
|
end
|
|
133
133
|
|
|
134
|
-
def
|
|
135
|
-
all('.ui-sortable .col-
|
|
134
|
+
def visible_numbers
|
|
135
|
+
all('.ui-sortable .col-number').map(&:text).map(&:to_i)
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
def move_up(element_id, by: 1, use_handle: true)
|
|
@@ -7,7 +7,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Move to top', type: :feature, js: tr
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def ordered_ids
|
|
10
|
-
Category.order(:
|
|
10
|
+
Category.order(:number).pluck(:id)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
before do
|
|
@@ -17,7 +17,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Move to top', type: :feature, js: tr
|
|
|
17
17
|
visit admin_categories_path(page: 2)
|
|
18
18
|
|
|
19
19
|
expect(visible_ids).to contain_exactly(4)
|
|
20
|
-
expect(
|
|
20
|
+
expect(visible_numbers).to contain_exactly(4)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'push element to top by clicking "move to top"' do
|
|
@@ -33,7 +33,7 @@ RSpec.describe ActiveAdmin::SortableTable, 'Move to top', type: :feature, js: tr
|
|
|
33
33
|
|
|
34
34
|
# I should see pushed elenent on the top
|
|
35
35
|
expect(visible_ids).to eq([4, 1, 2])
|
|
36
|
-
expect(
|
|
36
|
+
expect(visible_numbers).to eq([1, 2, 3])
|
|
37
37
|
expect(ordered_ids).to eq([4, 1, 2, 3])
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -43,8 +43,8 @@ RSpec.describe ActiveAdmin::SortableTable, 'Move to top', type: :feature, js: tr
|
|
|
43
43
|
all('.ui-sortable .col-id').map(&:text).map(&:to_i)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
def
|
|
47
|
-
all('.ui-sortable .col-
|
|
46
|
+
def visible_numbers
|
|
47
|
+
all('.ui-sortable .col-number').map(&:text).map(&:to_i)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
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.
|
|
4
|
+
version: 1.2.0
|
|
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:
|
|
13
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activeadmin
|
|
@@ -242,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
242
242
|
version: '0'
|
|
243
243
|
requirements: []
|
|
244
244
|
rubyforge_project:
|
|
245
|
-
rubygems_version: 2.
|
|
245
|
+
rubygems_version: 2.5.1
|
|
246
246
|
signing_key:
|
|
247
247
|
specification_version: 4
|
|
248
248
|
summary: Drag and drop reordering interface for ActiveAdmin tables
|
|
@@ -304,4 +304,3 @@ test_files:
|
|
|
304
304
|
- spec/rails_helper.rb
|
|
305
305
|
- spec/spec_helper.rb
|
|
306
306
|
- spec/support/wait_for_ajax.rb
|
|
307
|
-
has_rdoc:
|