activeadmin_reorderable 0.1.2 → 0.2.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
- SHA1:
3
- metadata.gz: 533fddb925c85604403ee6f2d3ad8e7f1f6aaa5d
4
- data.tar.gz: f5f3b26bdb74b288c1bf5b48297cd32e88722cfe
2
+ SHA256:
3
+ metadata.gz: 24e42e395b381a8fa33bce9aa9e8fb26e337b3f67519d5a998e720c94dac7f7e
4
+ data.tar.gz: 90475575d7098a30e8dc43b8a3536dcd6b4a9f42cf2a696face953002d504c9c
5
5
  SHA512:
6
- metadata.gz: d3e21bdf88afedd86426072e55789d0bc153efd7ca7cb9588f37cf55b2b8db0c9d2c53560329d33b61ce54475d549364ff2fe91ffb0155374d481f90987d5ef8
7
- data.tar.gz: 6a7ff481bdb0b4e1518137820cd344645962a4585364c7915e9005a4781354e4fb2a447474b403efe066a0cd3b58fa61b168e2538aeb6d6feeee4a0b987ed44c
6
+ metadata.gz: 399ec9fb0d7bd3217a40577e4ed3e3c980405cde55de5291db6a1d643c1881adcef7fcf33a9fc86cc47a234a50e7c3a9682ebd9ac805e39f84b431a35d5a832b
7
+ data.tar.gz: 5a29b1301e0e8477754ad4262aad074d58dd86770e0d9f167b396edf380c92f3e41e17cc33ca62d4e040f77538c55194ecfcd11877170da8e984b4e632e6df53
data/.gitignore CHANGED
@@ -1 +1,4 @@
1
1
  builds/*
2
+ Gemfile.lock
3
+ node_modules
4
+ *.gem
data/README.md CHANGED
@@ -8,10 +8,16 @@ Drag and drop to reorder your ActiveAdmin tables.
8
8
  Your resource classes must respond to `insert_at` ala the [`acts_as_list`](https://github.com/swanandp/acts_as_list) API. You don't need to use `acts_as_list`, but if you don't, make sure to define `insert_at`.
9
9
 
10
10
  ## Installation
11
+ ### Sprockets
11
12
  - Add `gem 'activeadmin_reorderable'` to `Gemfile`
12
13
  - Add `#= require activeadmin_reorderable` to `app/assets/javascripts/active_admin.js.coffee`
13
14
  - Add `@import "activeadmin_reorderable";` as the last `@import` statement in `app/assets/stylesheets/active_admin.css.scss`
14
15
 
16
+ ### Webpacker / npm
17
+ - `npm install --save activeadmin_reorderable` or `yarn add activeadmin_reorderable`
18
+ - Add `import "activeadmin_reorderable"` to your JS pack file
19
+ - Add `@import "activeadmin_reorderable/app/assets/styleseehts/activeadmin_reorderable.scss"";` to your CSS style file
20
+
15
21
  ## Use
16
22
  `parts.rb`
17
23
  ```ruby
@@ -53,10 +59,14 @@ ActiveAdmin.register Widget do
53
59
  end
54
60
  ```
55
61
 
56
- ***
62
+ ## Contributing
63
+
64
+ 1. Fork it ( https://github.com/[my-github-username]/activeadmin_reorderable/fork )
65
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
66
+ 3. Commit your changes (`git commit -am "Add some feature"`)
67
+ 4. Push to the branch (`git push origin my-new-feature`)
68
+ 5. Create a new Pull Request
57
69
 
58
- <a href="http://code.viget.com">
59
- <img src="http://code.viget.com/github-banner.png" alt="Code At Viget">
60
- </a>
70
+ ### Issue and PR reviews
61
71
 
62
- Visit [code.viget.com](http://code.viget.com) to see more projects from [Viget.](https://viget.com)
72
+ Another way you can help is by reviewing issues, trying to reproduce bugs, and providing feedback on PRs.
@@ -1,7 +1,7 @@
1
- $.fn.reorderable = function(opts) {
1
+ $.fn.reorderable = function (opts) {
2
2
  // This helper fixes the table row width collapsing when being dragged
3
3
  function reorderableTableHelper(e, ui) {
4
- ui.children().each(function() {
4
+ ui.children().each(function () {
5
5
  var $cell = $(this);
6
6
 
7
7
  $cell.width($cell.width());
@@ -18,16 +18,17 @@ $.fn.reorderable = function(opts) {
18
18
  }
19
19
 
20
20
  function reorderableTableStop(e, ui) {
21
- var $row = ui.item,
22
- $rows = $row.parent().children('tr'),
23
- $table = $row.closest('table'),
24
- $handle = $row.find('.reorder-handle'),
25
- url = $handle.data('reorder-url'),
26
- index = function(i) { return $rows.index(i) + 1; };
21
+ var $row = ui.item,
22
+ $rows = $row.parent().children('tr'),
23
+ $table = $row.closest('table'),
24
+ $handle = $row.find('.reorder-handle'),
25
+ url = $handle.data('reorder-url'),
27
26
 
28
- $table.find('tbody tr').each(function(index) {
29
- var $row = $(this),
30
- newClass = ''
27
+ index = function (i) { return $rows.index(i) + 1; };
28
+
29
+ $table.find('tbody tr').each(function (index) {
30
+ var $row = $(this),
31
+ newClass = ''
31
32
 
32
33
  $row.removeClass('odd').removeClass('even');
33
34
 
@@ -40,27 +41,33 @@ $.fn.reorderable = function(opts) {
40
41
  $row.addClass(newClass);
41
42
  });
42
43
 
43
- $rows.each(function() {
44
+ $rows.each(function () {
44
45
  $(this).find('.position').text(index($(this)));
45
46
  });
47
+ var top_id = $row.prev().find('.reorder-handle').data("reorderId")
48
+ var bottom_id = $row.next().find('.reorder-handle').data("reorderId")
46
49
 
47
- $.post(url, { position: index($row) });
50
+ $.post(url, {
51
+ position: index($row),
52
+ top_id: top_id,
53
+ bottom_id: bottom_id
54
+ });
48
55
  }
49
56
 
50
- return this.each(function() {
57
+ return this.each(function () {
51
58
  var opts = $.extend({
52
- items: 'tbody tr',
59
+ items: 'tbody tr',
53
60
  handle: '.reorder-handle',
54
- axis: 'y',
61
+ axis: 'y',
55
62
  helper: reorderableTableHelper,
56
- start: reorderableTableStart,
57
- stop: reorderableTableStop,
63
+ start: reorderableTableStart,
64
+ stop: reorderableTableStop,
58
65
  }, opts || {});
59
66
 
60
67
  $(this).sortable(opts);
61
68
  });
62
69
  };
63
70
 
64
- $(function() {
71
+ $(function () {
65
72
  $('.aa-reorderable').reorderable();
66
73
  });
@@ -11,12 +11,10 @@ module ActiveAdmin
11
11
  private
12
12
 
13
13
  def reorder_handle_for(resource)
14
- url = [
15
- active_admin_namespace.resource_for(resource.class).route_instance_path(resource),
16
- :reorder
17
- ].join('/')
14
+ aa_resource = active_admin_namespace.resource_for(resource.class)
15
+ url = aa_resource.route_member_action_path(:reorder, resource)
18
16
 
19
- span(reorder_handle_content, :class => 'reorder-handle', 'data-reorder-url' => url)
17
+ span(reorder_handle_content, :class => 'reorder-handle', 'data-reorder-url' => url, 'data-reorder-id' => resource.id)
20
18
  end
21
19
 
22
20
  def reorder_handle_content
@@ -28,4 +26,3 @@ module ActiveAdmin
28
26
  ::ActiveAdmin::Views::TableFor.send(:include, TableMethods)
29
27
  end
30
28
  end
31
-
@@ -1,3 +1,3 @@
1
1
  module ActiveadminReorderable
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.1"
3
3
  end
data/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "activeadmin_reorderable",
3
+ "version": "0.2.1",
4
+ "description": "Drag and drop to reorder your ActiveAdmin tables.",
5
+ "main": "app/assets/javascripts/activeadmin_reorderable.js",
6
+ "files": [
7
+ "app/**/*"
8
+ ],
9
+ "repository": "https://github.com/dkniffin/activeadmin_reorderable",
10
+ "author": "Viget <hello@viget.com>",
11
+ "license": "MIT",
12
+ "scripts": { },
13
+ "devDependencies": { },
14
+ "dependencies": {
15
+ "jquery": "^3.5.1"
16
+ }
17
+ }
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_reorderable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Jones
8
8
  - Lawson Kurtz
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-20 00:00:00.000000000 Z
12
+ date: 2022-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeadmin
@@ -48,11 +48,12 @@ files:
48
48
  - lib/activeadmin_reorderable.rb
49
49
  - lib/activeadmin_reorderable/engine.rb
50
50
  - lib/activeadmin_reorderable/version.rb
51
+ - package.json
51
52
  homepage: http://www.github.com/vigetlabs/activeadmin_reorderable
52
53
  licenses:
53
54
  - MIT
54
55
  metadata: {}
55
- post_install_message:
56
+ post_install_message:
56
57
  rdoc_options: []
57
58
  require_paths:
58
59
  - lib
@@ -67,9 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
69
70
  requirements: []
70
- rubyforge_project:
71
- rubygems_version: 2.4.5.1
72
- signing_key:
71
+ rubygems_version: 3.1.2
72
+ signing_key:
73
73
  specification_version: 4
74
74
  summary: Drag and drop reordering for ActiveAdmin tables
75
75
  test_files: []