lol_sortable 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record/lol_sortable.rb +24 -0
- data/lib/generators/lol_sortable/add_model_generator.rb +13 -0
- data/lib/lol_sortable.rb +1 -0
- data/lib/lol_sortable/version.rb +1 -1
- metadata +24 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff4fba10fb17c5baf532d4d854c0bc95f54fd3f9
|
4
|
+
data.tar.gz: 23c3b1569fe58d20e71906623645a8770391f64d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0f714510f589113a279348cd4c71324aa055cbd0d20d0e3538bf34d18b91d6b2aa3a5fc1ccba3b61054e6e00946de06a4446034a68a77291960cd227b3ac300
|
7
|
+
data.tar.gz: fbe97a550c3d4b56a4701ba0070c686fec74a25311bc6803be6c68907ff84154c432a28084f4f79b22fc839a4e1ed657e2d7dca3206720b82523b6efa6e2cbf2
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module LolSortable
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
scope :prioritized, -> {order('priority ASC')}
|
7
|
+
|
8
|
+
before_save :set_default_priority
|
9
|
+
|
10
|
+
def set_default_priority
|
11
|
+
self.priority = 3000 if self.priority == 0
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module ClassMethods
|
16
|
+
def prioritize(list_ids)
|
17
|
+
list_ids.each_with_index do |id, index|
|
18
|
+
resource = self.find id
|
19
|
+
resource.update_attribute(:priority, index + 1)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#endoding: utf-8
|
2
|
+
module LolSortable
|
3
|
+
class AddModelGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
argument :model_name, :required => true, :default => nil
|
7
|
+
|
8
|
+
def create_migration_to_model
|
9
|
+
run "bundle exec rails g active_record:migration AddPriorityTo#{model_name.camelize} priority:integer"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
data/lib/lol_sortable.rb
CHANGED
data/lib/lol_sortable/version.rb
CHANGED
metadata
CHANGED
@@ -1,90 +1,92 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lol_sortable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Zaghi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jquery-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: jquery-ui-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: sqlite3
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
type: :
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
description: Sort yours models with mongoid, jquery.ui.sortable
|
68
|
+
version: '0'
|
69
|
+
description: Sort yours models with mongoid or active_record, jquery.ui.sortable
|
70
70
|
email:
|
71
71
|
- eduardo@loldesign.com.br
|
72
72
|
executables: []
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- MIT-LICENSE
|
77
|
+
- README.rdoc
|
78
|
+
- Rakefile
|
76
79
|
- app/assets/javascripts/lol_sortable/sortable.js
|
77
80
|
- app/controllers/sortable_controller.rb
|
78
81
|
- config/routes.rb
|
82
|
+
- lib/active_record/lol_sortable.rb
|
83
|
+
- lib/generators/lol_sortable/add_model_generator.rb
|
79
84
|
- lib/generators/lol_sortable/install_generator.rb
|
85
|
+
- lib/lol_sortable.rb
|
80
86
|
- lib/lol_sortable/engine.rb
|
81
87
|
- lib/lol_sortable/version.rb
|
82
|
-
- lib/lol_sortable.rb
|
83
88
|
- lib/mongoid/lol_sortable.rb
|
84
89
|
- lib/tasks/lol_sortable_tasks.rake
|
85
|
-
- MIT-LICENSE
|
86
|
-
- Rakefile
|
87
|
-
- README.rdoc
|
88
90
|
homepage: http://www.loldesign.com.br
|
89
91
|
licenses: []
|
90
92
|
metadata: {}
|
@@ -94,17 +96,17 @@ require_paths:
|
|
94
96
|
- lib
|
95
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
98
|
requirements:
|
97
|
-
- -
|
99
|
+
- - ">="
|
98
100
|
- !ruby/object:Gem::Version
|
99
101
|
version: '0'
|
100
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
103
|
requirements:
|
102
|
-
- -
|
104
|
+
- - ">="
|
103
105
|
- !ruby/object:Gem::Version
|
104
106
|
version: '0'
|
105
107
|
requirements: []
|
106
108
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.2.2
|
108
110
|
signing_key:
|
109
111
|
specification_version: 4
|
110
112
|
summary: Sort your models with jquery sortable
|