activeadmin_reorderable 0.1.2 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 533fddb925c85604403ee6f2d3ad8e7f1f6aaa5d
4
- data.tar.gz: f5f3b26bdb74b288c1bf5b48297cd32e88722cfe
2
+ SHA256:
3
+ metadata.gz: a3444cc5455393598880575853ae90a3fa3c96ad70db05266319ca3f11175321
4
+ data.tar.gz: 4f61654aee46f935210df56e3ff98702538a0bd455937b57d3ad19f766d4e92b
5
5
  SHA512:
6
- metadata.gz: d3e21bdf88afedd86426072e55789d0bc153efd7ca7cb9588f37cf55b2b8db0c9d2c53560329d33b61ce54475d549364ff2fe91ffb0155374d481f90987d5ef8
7
- data.tar.gz: 6a7ff481bdb0b4e1518137820cd344645962a4585364c7915e9005a4781354e4fb2a447474b403efe066a0cd3b58fa61b168e2538aeb6d6feeee4a0b987ed44c
6
+ metadata.gz: e8b5032d8e89cd76d8649656e240509296b9dd4b150c9a5ac5fa4e5c84bd1f6753ed2a400dc2cc4954b0ecaae5fd776885747f97973e1ca701a2bbc225f2d4c1
7
+ data.tar.gz: 9e68c6debce31865ba13d2ed203ae2317ad06cb42040b6308590ab8db4b3ea921de6b2e0e61b11448f9b869fa8b568ed2e477c98878370d14fa26a489070b515
data/README.md CHANGED
@@ -53,10 +53,14 @@ ActiveAdmin.register Widget do
53
53
  end
54
54
  ```
55
55
 
56
- ***
56
+ ## Contributing
57
57
 
58
- <a href="http://code.viget.com">
59
- <img src="http://code.viget.com/github-banner.png" alt="Code At Viget">
60
- </a>
58
+ 1. Fork it ( https://github.com/[my-github-username]/activeadmin_reorderable/fork )
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am "Add some feature"`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create a new Pull Request
61
63
 
62
- Visit [code.viget.com](http://code.viget.com) to see more projects from [Viget.](https://viget.com)
64
+ ### Issue and PR reviews
65
+
66
+ 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,12 @@ 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
+ instance_name = aa_resource.resources_configuration[:self][:route_instance_name]
18
16
 
19
- span(reorder_handle_content, :class => 'reorder-handle', 'data-reorder-url' => url)
17
+ url = send([:reorder, aa_resource.route_prefix, instance_name, :path].join('_'), resource)
18
+
19
+ span(reorder_handle_content, :class => 'reorder-handle', 'data-reorder-url' => url, 'data-reorder-id' => resource.id)
20
20
  end
21
21
 
22
22
  def reorder_handle_content
@@ -1,3 +1,3 @@
1
1
  module ActiveadminReorderable
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.5"
3
3
  end
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.1.5
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: 2021-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeadmin
@@ -52,7 +52,7 @@ homepage: http://www.github.com/vigetlabs/activeadmin_reorderable
52
52
  licenses:
53
53
  - MIT
54
54
  metadata: {}
55
- post_install_message:
55
+ post_install_message:
56
56
  rdoc_options: []
57
57
  require_paths:
58
58
  - lib
@@ -67,9 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubyforge_project:
71
- rubygems_version: 2.4.5.1
72
- signing_key:
70
+ rubygems_version: 3.1.2
71
+ signing_key:
73
72
  specification_version: 4
74
73
  summary: Drag and drop reordering for ActiveAdmin tables
75
74
  test_files: []