ztree 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ztree.rb +1 -4
- data/lib/ztree/order_column.rb +8 -0
- data/lib/ztree/sort_tree.rb +8 -3
- data/ztree.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ecc8b84bf58c253b43ae10f9f347a29afbf142d
|
4
|
+
data.tar.gz: 4c5d21f20e35a9cbf0fb7946cec70f0e207b875e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ba23458c1449c1c9c12d799c10eb0426dae17df06007ece91539b4b1df8254f6cfa5bebcf0b7d0afdd049eae0b5bd2399daab13c101f2d3c60abadcd1439be0
|
7
|
+
data.tar.gz: 2a12ebad29a8c3e10239861de7ac4d9104577533e69aa1b7f64e991745324a57eb074b8dbd92ded71cf9813115db37dfd97fadcf32543dabc3c2d8dd80f0c655
|
data/lib/ztree.rb
CHANGED
@@ -2,14 +2,11 @@ require "rails"
|
|
2
2
|
require "exts/hash"
|
3
3
|
require "exts/array"
|
4
4
|
require "assets/rails/engine"
|
5
|
+
require "ztree/order_column"
|
5
6
|
require "ztree/sort_tree"
|
6
7
|
require "ztree/controller"
|
7
8
|
require "ztree/helpers"
|
8
9
|
|
9
|
-
module Ztrr
|
10
|
-
autoload :Controller, 'ztree/controller'
|
11
|
-
end
|
12
|
-
|
13
10
|
class ActionController::Base
|
14
11
|
include Ztree::Controller
|
15
12
|
end
|
data/lib/ztree/sort_tree.rb
CHANGED
@@ -17,10 +17,14 @@ module SortTree
|
|
17
17
|
def all_parents
|
18
18
|
all.select {|c| c.has_children? || c.ancestry.nil?}
|
19
19
|
end
|
20
|
+
|
21
|
+
def order_column
|
22
|
+
:order_num
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
def sorted_children
|
23
|
-
children.sort_by{|c| c.
|
27
|
+
children.sort_by{|c| c.send(self.class.order_column)}
|
24
28
|
end
|
25
29
|
|
26
30
|
def sorted_children_ids
|
@@ -32,11 +36,12 @@ module SortTree
|
|
32
36
|
end
|
33
37
|
|
34
38
|
def update_order(num)
|
35
|
-
update_attribute(
|
39
|
+
update_attribute(self.class.order_column, num)
|
36
40
|
end
|
37
41
|
|
38
42
|
def update_sorted_numbers(numbers)
|
39
43
|
return false if numbers.size != children.size
|
40
44
|
self.class.update_sorted_numbers(numbers)
|
41
45
|
end
|
42
|
-
|
46
|
+
|
47
|
+
end
|
data/ztree.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zhimeng Sun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jquery-rails
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/ztree.rb
|
39
39
|
- lib/ztree/controller.rb
|
40
40
|
- lib/ztree/helpers.rb
|
41
|
+
- lib/ztree/order_column.rb
|
41
42
|
- lib/ztree/railtie.rb
|
42
43
|
- lib/ztree/sort_tree.rb
|
43
44
|
- vendor/assets/images/diy/1_close.png
|