activeadmin-sortable 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -5,9 +5,11 @@ sortable via a drag-and-drop interface.
|
|
5
5
|
|
6
6
|
## Prerequisites
|
7
7
|
|
8
|
-
This extension assumes that you're using
|
9
|
-
|
10
|
-
|
8
|
+
This extension assumes that you're using one of the following on any model you want to be sortable.
|
9
|
+
|
10
|
+
#### ActiveRecord
|
11
|
+
|
12
|
+
[acts_as_list](https://github.com/rails/acts_as_list)
|
11
13
|
|
12
14
|
```ruby
|
13
15
|
class Page < ActiveRecord::Base
|
@@ -15,6 +17,17 @@ class Page < ActiveRecord::Base
|
|
15
17
|
end
|
16
18
|
```
|
17
19
|
|
20
|
+
#### Mongoid
|
21
|
+
|
22
|
+
[mongoid_orderable](https://github.com/pyromaniac/mongoid_orderable)
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
class Page < ActiveRecord::Base
|
26
|
+
include Mongoid::Orderable
|
27
|
+
orderable
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
18
31
|
## Usage
|
19
32
|
|
20
33
|
### Add it to your Gemfile
|
@@ -29,6 +42,11 @@ gem 'activeadmin-sortable'
|
|
29
42
|
//= require activeadmin-sortable
|
30
43
|
```
|
31
44
|
|
45
|
+
### Include the Stylesheet in active_admin.css
|
46
|
+
```css
|
47
|
+
//= require activeadmin-sortable
|
48
|
+
```
|
49
|
+
|
32
50
|
### Configure your ActiveAdmin Resource
|
33
51
|
|
34
52
|
```ruby
|
@@ -0,0 +1 @@
|
|
1
|
+
.activeadmin-sortable .handle { cursor: ns-resize; }
|
data/lib/activeadmin-sortable.rb
CHANGED
@@ -7,7 +7,12 @@ module ActiveAdmin
|
|
7
7
|
module ControllerActions
|
8
8
|
def sortable
|
9
9
|
member_action :sort, :method => :post do
|
10
|
-
|
10
|
+
if defined?(::Mongoid::Orderable) &&
|
11
|
+
resource.class.included_modules.include?(::Mongoid::Orderable)
|
12
|
+
resource.move_to! params[:position].to_i
|
13
|
+
else
|
14
|
+
resource.insert_at params[:position].to_i
|
15
|
+
end
|
11
16
|
head 200
|
12
17
|
end
|
13
18
|
end
|
@@ -17,8 +22,8 @@ module ActiveAdmin
|
|
17
22
|
HANDLE = '↕'.html_safe
|
18
23
|
|
19
24
|
def sortable_handle_column
|
20
|
-
column '' do |resource|
|
21
|
-
sort_url =
|
25
|
+
column '', :class => "activeadmin-sortable" do |resource|
|
26
|
+
sort_url = resource_path(resource) + "/sort"
|
22
27
|
content_tag :span, HANDLE, :class => 'handle', 'data-sort-url' => sort_url
|
23
28
|
end
|
24
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin-sortable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,14 +9,14 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeadmin
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0.4'
|
22
22
|
type: :runtime
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0.4'
|
30
30
|
description: Drag and drop sort interface for ActiveAdmin tables
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- Rakefile
|
42
42
|
- activeadmin-sortable.gemspec
|
43
43
|
- app/assets/javascripts/activeadmin-sortable.js
|
44
|
+
- app/assets/stylesheets/activeadmin-sortable.css
|
44
45
|
- lib/activeadmin-sortable.rb
|
45
46
|
- lib/activeadmin-sortable/version.rb
|
46
47
|
homepage: https://github.com/newcontext/activeadmin-sortable
|
@@ -55,22 +56,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
56
|
- - ! '>='
|
56
57
|
- !ruby/object:Gem::Version
|
57
58
|
version: '0'
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
hash: -1888499648567453647
|
61
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
60
|
none: false
|
63
61
|
requirements:
|
64
62
|
- - ! '>='
|
65
63
|
- !ruby/object:Gem::Version
|
66
64
|
version: '0'
|
67
|
-
segments:
|
68
|
-
- 0
|
69
|
-
hash: -1888499648567453647
|
70
65
|
requirements: []
|
71
66
|
rubyforge_project:
|
72
|
-
rubygems_version: 1.8.
|
67
|
+
rubygems_version: 1.8.23
|
73
68
|
signing_key:
|
74
69
|
specification_version: 3
|
75
70
|
summary: Drag and drop sort interface for ActiveAdmin tables
|
76
71
|
test_files: []
|
72
|
+
has_rdoc:
|