activeadmin_reorderable 0.1.2 → 0.1.5
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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a3444cc5455393598880575853ae90a3fa3c96ad70db05266319ca3f11175321
|
4
|
+
data.tar.gz: 4f61654aee46f935210df56e3ff98702538a0bd455937b57d3ad19f766d4e92b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
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
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
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, {
|
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:
|
59
|
+
items: 'tbody tr',
|
53
60
|
handle: '.reorder-handle',
|
54
|
-
axis:
|
61
|
+
axis: 'y',
|
55
62
|
helper: reorderableTableHelper,
|
56
|
-
start:
|
57
|
-
stop:
|
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
|
-
|
15
|
-
|
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
|
-
|
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
|
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.
|
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:
|
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
|
-
|
71
|
-
|
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: []
|