ancestry-treeview 0.0.1 → 0.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.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/README.md +16 -20
- data/ancestry-treeview.gemspec +2 -1
- data/lib/ancestry/treeview/instance_methods.rb +3 -0
- data/lib/ancestry/treeview/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0b31521037d453e7d8ead165e790c37b78baa5e
|
|
4
|
+
data.tar.gz: a96e55875fe4ac4a7386b740cf03a3aa644a379d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc9df7ee354de205dd430d4d16d68b6569faec7f83cbf100b83ce291fd7aea9738f4f6e56ef97bdb002a3fcdc59bfda3deb021eba9cd098c6d2a34e462143bd4
|
|
7
|
+
data.tar.gz: 12779fd96f0e65439fd49fba59f066adae4a8643d83ea36f143df12a921e6ea1abd06dc7acd073a6e5565f486218d5f6ff8f43944ffaeb51939703d05e59b907
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -1,46 +1,42 @@
|
|
|
1
1
|
# ancestry-treeview [](http://travis-ci.org/sonots/ancestry-treeview) [](https://gemnasium.com/sonots/ancestry-treeview)
|
|
2
2
|
|
|
3
|
-
testing ruby: 1.9.
|
|
3
|
+
testing ruby: 1.9.3, 2.0.0; ancestry: 2.0.0
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ancestry-treeview is an extension of ancestry gem to show a tree view which looks like http://jsfiddle.net/Fh47n/.
|
|
5
|
+
ancestry-treeview is an extension of `ancestry` gem to show a tree view which looks like http://jsfiddle.net/Fh47n/.
|
|
8
6
|
|
|
9
7
|
## Install
|
|
10
8
|
|
|
11
9
|
gem install ancestry-treeview
|
|
12
10
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
jquery, and rails are required.
|
|
11
|
+
## Usage
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
### Basic Usage
|
|
18
14
|
|
|
19
|
-
Add the following in your app/assets/stylesheets/application.css.scss
|
|
15
|
+
Add the following code in your `app/assets/stylesheets/application.css.scss`
|
|
20
16
|
|
|
21
17
|
@import "ancestry-treeview";
|
|
22
18
|
|
|
23
19
|
Then, call
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
in your view where `model` is your `ancestry` model.
|
|
21
|
+
node.tree
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
in your view where `node` is your `ancestry` model.
|
|
30
24
|
|
|
31
|
-
|
|
25
|
+
### Custom Link
|
|
32
26
|
|
|
33
|
-
|
|
27
|
+
Default html links in the tree view are as
|
|
34
28
|
|
|
35
|
-
|
|
29
|
+
<a href="#">id</a>
|
|
30
|
+
|
|
31
|
+
You can change the html link by giving a block as
|
|
36
32
|
|
|
37
|
-
|
|
33
|
+
node.tree {|node| link_to("text", your_controller_path(node)) }
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
### Contraint Depth
|
|
40
36
|
|
|
41
|
-
As default, all childrens of
|
|
37
|
+
As default, all childrens of a node is shown as a tree. Use `to_depth` option to contraint the depth
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
node.tree(to_depth: 1)
|
|
44
40
|
|
|
45
41
|
## Acknowledgements
|
|
46
42
|
|
data/ancestry-treeview.gemspec
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#! /usr/bin/env gem build
|
|
2
2
|
# encoding: utf-8
|
|
3
|
-
|
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
|
4
|
+
require 'ancestry/treeview/version'
|
|
4
5
|
|
|
5
6
|
Gem::Specification.new do |gem|
|
|
6
7
|
gem.name = 'ancestry-treeview'
|
|
@@ -3,6 +3,9 @@ module Ancestry
|
|
|
3
3
|
def tree(params = {})
|
|
4
4
|
return '' unless self
|
|
5
5
|
subtree = (params[:to_depth].present? ? self.subtree(to_depth: params[:to_depth]) : self.subtree).order('path ASC')
|
|
6
|
+
if params[:conditions].is_a?(Array) || params[:conditions].is_a?(Hash)
|
|
7
|
+
subtree = subtree.where(params[:conditions])
|
|
8
|
+
end
|
|
6
9
|
html = '<div class="ancestry-treeview">'
|
|
7
10
|
open_ul = 0
|
|
8
11
|
prev_depth = self.depth - 1
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ancestry-treeview
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Naotoshi Seo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-
|
|
11
|
+
date: 2013-07-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ancestry
|
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
107
107
|
version: '0'
|
|
108
108
|
requirements: []
|
|
109
109
|
rubyforge_project:
|
|
110
|
-
rubygems_version: 2.0.
|
|
110
|
+
rubygems_version: 2.0.3
|
|
111
111
|
signing_key:
|
|
112
112
|
specification_version: 4
|
|
113
113
|
summary: An extension of ancestry gem to show a tree view
|