activeadmin_sortable_table 1.1.3 → 1.2.0

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: 66207fb91f6c2abf4f7a29107fabb9ace050c52f
4
- data.tar.gz: 679a10bc3b27667d32fe43a9a86dd14855bed9d7
3
+ metadata.gz: bad6787846d549ac47bef5f8c6b56431f5bef5dd
4
+ data.tar.gz: c8c9be5b01fd966f8807f2c5645157100050f698
5
5
  SHA512:
6
- metadata.gz: f5ce91b8a8994c8322f90e941a4c5ba01cf7bcd0de42e5080eac43f8067969f0ab18871f945311f5b3a87ed276dd07e73b8045ec0f0a5c9e08754ef08ba86f48
7
- data.tar.gz: 3686d18158dc53c1adaf5a581e72cced145057f33a8239e22448ed092b020e045b4302b3106eddecfbf9675eb78785b7bfd3324e3ddf91d5f333b3c24479193d
6
+ metadata.gz: ca386a268b779c503a074f5c3e1eee2da272b342c4716628ae7b957c1a5ed8f742434b14454ed87d986c0465f7c929e2c7abea1e364accb1fbb3f97eea4e1185
7
+ data.tar.gz: b5ae41b61014415bdb5fb47619901a6429b19a4b19a805f4c86c35982950e5eab3f0904b72a6ac7865ad693deb6f7469e63d8545c2b1d6c251572326b3ff88fc
@@ -1,3 +1,7 @@
1
+ 1.2.0
2
+
3
+ * **Feature**. Now it is possible to specify an acts_as_list column other than position @faucct
4
+
1
5
  1.1.3
2
6
 
3
7
  * **Fix**. Reordering was broken.
@@ -19,7 +19,7 @@ GIT
19
19
  PATH
20
20
  remote: .
21
21
  specs:
22
- activeadmin_sortable_table (1.1.3)
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.9.8.0)
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.10.6
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.position) + move_to_top_handle(options)
41
+ sort_handle(options, resource.send(resource.position_column)) + move_to_top_handle(options)
42
42
  end
43
43
  end
44
44
 
@@ -1,6 +1,6 @@
1
1
  module ActiveAdmin
2
2
  #
3
3
  module SortableTable
4
- VERSION = '1.1.3'
4
+ VERSION = '1.2.0'
5
5
  end
6
6
  end
@@ -1,13 +1,13 @@
1
1
  ActiveAdmin.register Category do
2
2
  include ActiveAdmin::SortableTable
3
- permit_params :id, :position
4
- config.sort_order = 'position_asc'
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 :position
10
+ column :number
11
11
  actions
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  class Category < ActiveRecord::Base
2
- acts_as_list
2
+ acts_as_list column: :number
3
3
  end
@@ -1,7 +1,7 @@
1
1
  class CreateCategories < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :categories do |t|
4
- t.integer :position
4
+ t.integer :number
5
5
  end
6
6
  end
7
7
  end
@@ -30,7 +30,7 @@ ActiveRecord::Schema.define(version: 20150910072505) do
30
30
 
31
31
  create_table "categories", force: :cascade do |t|
32
32
  t.string "name"
33
- t.integer "position"
33
+ t.integer "number"
34
34
  end
35
35
 
36
36
  end
@@ -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(:position).pluck(:id)
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(visible_positions).to eq([1, 2, 3])
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 position' do
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(visible_positions).to eq([1, 2, 3])
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(visible_positions).to eq([1, 2, 3])
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(visible_positions).to eq([1, 2, 3])
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(visible_positions).to eq([1, 2, 3])
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(visible_positions).to eq([1, 2, 3])
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(visible_positions).to eq([4, 5, 6])
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(visible_positions).to eq([4, 5, 6])
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(visible_positions).to eq([4, 5, 6])
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(visible_positions).to eq([4, 5, 6])
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(visible_positions).to eq([4, 5, 6])
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(visible_positions).to eq([4, 5, 6])
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 visible_positions
135
- all('.ui-sortable .col-position').map(&:text).map(&:to_i)
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(:position).pluck(:id)
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(visible_positions).to contain_exactly(4)
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(visible_positions).to eq([1, 2, 3])
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 visible_positions
47
- all('.ui-sortable .col-position').map(&:text).map(&:to_i)
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.1.3
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: 2015-10-23 00:00:00.000000000 Z
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.4.8
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: