tree_view 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,7 +9,7 @@ http://benzhang.me/files/medium_tree_view.jpg
9
9
  Installation
10
10
  ===========
11
11
 
12
- Put this line of code to your gemfile
12
+ Add this line to your gemfile
13
13
 
14
14
  ```ruby
15
15
  gem 'tree_view'
@@ -24,9 +24,10 @@ rails g tree_view:install
24
24
  include necessary javascript and stylesheet files.
25
25
 
26
26
  ```ruby
27
- //= require jquery.dimensions.min
28
- //= require jquery.drawinglibrary
29
- //= require jquery.svg.min
27
+ //= require jquery.dimensions.min.js
28
+ //= require jquery.drawinglibrary.js
29
+ //= require jquery.svg.min.js
30
+ //= require tree_view.drawline.js
30
31
  ```
31
32
 
32
33
  Example
@@ -34,14 +35,17 @@ Example
34
35
 
35
36
  If you have a model with tree structure (you might use tree or ancestry gem), you can simple invoke tree_view helper, and pass the root node of the tree.
36
37
 
38
+ In controller
39
+
37
40
  ```ruby
38
- <%= tree_view(@root) %>
41
+ @root = Policy.root
39
42
  ```
40
43
 
41
- The attributes name is the name of the attribute that you want to display on the tree node.
44
+ In View
42
45
 
43
- If you are using other name instead of parent_id in your database, you can simple set the parent_name to whatever you call it on your database, such as
44
- build_tree_view(model, attribute name, :parent_name => 'parent')
46
+ ```ruby
47
+ <%= tree_view(@root) %>
48
+ ```
45
49
 
46
50
  API Doc
47
51
  =======
@@ -1,3 +1,3 @@
1
1
  module TreeView
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -36,7 +36,12 @@ module TreeView
36
36
  </span>
37
37
  </div>
38
38
  EOF
39
- root.children.sort_by{|c| c.position }.each do |child|
39
+ if opt.has_key?(:order_by)
40
+ children = root.children.sort_by{|c| c.attributes[opt[:order_by]] }
41
+ else
42
+ children = root.children
43
+ end
44
+ children.each do |child|
40
45
  code = builder(child, opt, &block)
41
46
  result += code[0]
42
47
  if drawline
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tree_view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-19 00:00:00.000000000 Z
12
+ date: 2012-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2151949480 !ruby/object:Gem::Requirement
16
+ requirement: &2155888860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2151949480
24
+ version_requirements: *2155888860
25
25
  description: view helper to generate tree view chart
26
26
  email:
27
27
  - bzbnhang@gmail.com