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 +12 -8
- data/lib/tree_view/version.rb +1 -1
- data/lib/tree_view/view_helpers/action_view.rb +6 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -9,7 +9,7 @@ http://benzhang.me/files/medium_tree_view.jpg
|
|
9
9
|
Installation
|
10
10
|
===========
|
11
11
|
|
12
|
-
|
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
|
-
|
41
|
+
@root = Policy.root
|
39
42
|
```
|
40
43
|
|
41
|
-
|
44
|
+
In View
|
42
45
|
|
43
|
-
|
44
|
-
|
46
|
+
```ruby
|
47
|
+
<%= tree_view(@root) %>
|
48
|
+
```
|
45
49
|
|
46
50
|
API Doc
|
47
51
|
=======
|
data/lib/tree_view/version.rb
CHANGED
@@ -36,7 +36,12 @@ module TreeView
|
|
36
36
|
</span>
|
37
37
|
</div>
|
38
38
|
EOF
|
39
|
-
|
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.
|
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-
|
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: &
|
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: *
|
24
|
+
version_requirements: *2155888860
|
25
25
|
description: view helper to generate tree view chart
|
26
26
|
email:
|
27
27
|
- bzbnhang@gmail.com
|