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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccb07a9b7f8965bf05a1bc83299278141e67c3b4
4
- data.tar.gz: ccf00d5d61a1da7fda1fd9768b4764f8f683905e
3
+ metadata.gz: 2ecc8b84bf58c253b43ae10f9f347a29afbf142d
4
+ data.tar.gz: 4c5d21f20e35a9cbf0fb7946cec70f0e207b875e
5
5
  SHA512:
6
- metadata.gz: a7b21e405fbf48fc507eb17a113d2c66137b44471539849eab8d4de838e6727662cef8c25d8f4ae48def9e60ff9f655df7d0dc3a163a98764e04f4f27314e52f
7
- data.tar.gz: 955976670af61e244171df895f49feced19bf059d7e4bba5769d2c9b5ec390a58789fa1f1a9ee49a3ee7360ada79c3657c60abaf7068ad189856488199c024b4
6
+ metadata.gz: 4ba23458c1449c1c9c12d799c10eb0426dae17df06007ece91539b4b1df8254f6cfa5bebcf0b7d0afdd049eae0b5bd2399daab13c101f2d3c60abadcd1439be0
7
+ data.tar.gz: 2a12ebad29a8c3e10239861de7ac4d9104577533e69aa1b7f64e991745324a57eb074b8dbd92ded71cf9813115db37dfd97fadcf32543dabc3c2d8dd80f0c655
@@ -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
@@ -0,0 +1,8 @@
1
+ class << ActiveRecord::Base
2
+ def ztrees(opts = {}) # 暂时简单实现
3
+ cattr_accessor :order_column
4
+ self.order_column = opts[:order_column] || :order_num
5
+ end
6
+ end
7
+
8
+
@@ -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.order_num}
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(:order_num, num)
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
- end
46
+
47
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ztree'
5
- s.version = '0.0.4'
5
+ s.version = '0.0.5'
6
6
  s.authors = ['Zhimeng Sun']
7
7
  s.email = ['zhimengSun@gmail.com']
8
8
  s.homepage = 'https://github.com/zhimengSun/ztree'
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
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: 2013-12-07 00:00:00.000000000 Z
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