tree_view 0.1.8 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +19 -1
- data/lib/assets/stylesheets/tree_view.sass +0 -3
- data/lib/tree_view/version.rb +1 -1
- data/lib/tree_view/view_helpers/action_view.rb +10 -4
- metadata +4 -4
data/README.md
CHANGED
@@ -23,6 +23,7 @@ rails g tree_view:install
|
|
23
23
|
|
24
24
|
include necessary javascript and stylesheet files.
|
25
25
|
|
26
|
+
Add these files to your application.js
|
26
27
|
```ruby
|
27
28
|
//= require jquery.dimensions.min.js
|
28
29
|
//= require jquery.drawinglibrary.js
|
@@ -30,6 +31,10 @@ include necessary javascript and stylesheet files.
|
|
30
31
|
//= require tree_view.drawline.js
|
31
32
|
```
|
32
33
|
|
34
|
+
Add the stylesheet to your application.css
|
35
|
+
```ruby
|
36
|
+
//= require tree_view
|
37
|
+
```
|
33
38
|
Example
|
34
39
|
=======
|
35
40
|
|
@@ -47,9 +52,22 @@ In View
|
|
47
52
|
<%= tree_view(@root) %>
|
48
53
|
```
|
49
54
|
|
55
|
+
To customise the content or each view you can simple pass a block and can
|
56
|
+
|
50
57
|
API Doc
|
51
58
|
=======
|
52
59
|
|
53
|
-
|
60
|
+
```ruby
|
61
|
+
# generate html tree view helper
|
62
|
+
#
|
63
|
+
# @param root [model instance] the root node of the tree structure
|
64
|
+
# @param opt [Hash] the options to generate tree nodes
|
65
|
+
# :css [String] the wrapper div's css
|
66
|
+
# :drawline [true, false] whether draw lines among each nodes
|
67
|
+
# :node_css [String] the css for each node
|
68
|
+
# :order_by [sym] the order of the children
|
69
|
+
# @param &block [code block] if you want to customise the content of each tree node, just passing a code block
|
70
|
+
def tree_view(root, opt = {}, &block)
|
71
|
+
```
|
54
72
|
|
55
73
|
Copyright (c) 2011 Ben Zhang, released under the MIT license
|
data/lib/tree_view/version.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
module TreeView
|
2
2
|
|
3
3
|
module ActionView
|
4
|
-
|
4
|
+
# generate html tree view helper
|
5
|
+
#
|
6
|
+
# @param root [model instance] the root node of the tree structure
|
7
|
+
# @param opt [Hash] the options to generate tree nodes
|
8
|
+
# :css [String] the wrapper div's css
|
9
|
+
# :drawline [true, false] whether draw lines among each nodes
|
10
|
+
# :node_css [String] the css for each node
|
11
|
+
# :order_by [sym] the order of the children
|
12
|
+
# @param &block [code block] if you want to customise the content of each tree node, just passing a code block
|
5
13
|
def tree_view(root, opt = {}, &block)
|
6
14
|
css = opt[:css] || "treeview"
|
7
15
|
drawline = opt.has_key?(:drawline) ? opt[:drawline] : true
|
@@ -23,9 +31,7 @@ module TreeView
|
|
23
31
|
if block_given?
|
24
32
|
content = capture(root, &block)
|
25
33
|
else
|
26
|
-
content =
|
27
|
-
#{image_position root.entry_type}<a href="#">#{root.entry_type == 'root' ? 'Organisation Chart' : truncate(root.name, :length => 20)}</a>
|
28
|
-
EOF
|
34
|
+
content = "<a href='#'>#{truncate(root.name, :length => 20)}</a>"
|
29
35
|
end
|
30
36
|
result, script = "", ""
|
31
37
|
html = <<-EOF
|
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.
|
4
|
+
version: '0.2'
|
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-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2151806360 !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: *2151806360
|
25
25
|
description: view helper to generate tree view chart
|
26
26
|
email:
|
27
27
|
- bzbnhang@gmail.com
|