ztree 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/exts/array.rb +1 -1
- data/lib/ztree/sort_tree.rb +4 -0
- data/ztree.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d94fdf5dd3c4202a47c8308f9ce276c0dec7566
|
4
|
+
data.tar.gz: 9f9e2fb6bbb2b3dc3302535a3ab9299ecc03e8a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17a312d3032859f56a2062174d5f103e3e7c4e59e8c09d2244a1f38dc7bc73cc7b623d8da584325b3dd78f4d8d793756967b6e5c39e163b2df92e56bccba367b
|
7
|
+
data.tar.gz: c9e3bcf5e5cd0415c6fcf0a58c3db7d710e375d22a373c90b30c34aa4347e06b073fd49dd5c51eea5f4fb135a000d41b69e61983db10b161c8ff0afcb865bed0
|
data/lib/exts/array.rb
CHANGED
@@ -28,6 +28,6 @@ class Array
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def to_sorted_nodes
|
31
|
-
self.group_by(&:parent_id).each {|k,v| v.sort_by!
|
31
|
+
self.group_by(&:parent_id).each {|k,v| v.sort_by! {|a| a.send(a.class.order_column) }}.to_a.flatten.select{|c| !c.is_a?Integer}.compact
|
32
32
|
end
|
33
33
|
end
|
data/lib/ztree/sort_tree.rb
CHANGED
@@ -21,6 +21,10 @@ module SortTree
|
|
21
21
|
def order_column
|
22
22
|
:order_num
|
23
23
|
end
|
24
|
+
|
25
|
+
def to_sorted_nodes(c = '')
|
26
|
+
where(c).group_by(&:parent_id).each {|k,v| v.sort_by! &(order_column.to_sym)}.to_a.flatten.select{|c| !c.is_a?Integer}.compact
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
def sorted_children
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zhimeng Sun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jquery-rails
|