Commit f969a043 authored by yann300's avatar yann300

retrieve node at specific path

parent 97c3429e
...@@ -42,6 +42,7 @@ class TreeView { ...@@ -42,6 +42,7 @@ class TreeView {
this.formatSelf = opts.formatSelf || this.formatSelfDefault this.formatSelf = opts.formatSelf || this.formatSelfDefault
this.view = null this.view = null
this.nodeIsExpanded = {} this.nodeIsExpanded = {}
this.nodes = {}
} }
render (json) { render (json) {
...@@ -86,6 +87,7 @@ class TreeView { ...@@ -86,6 +87,7 @@ class TreeView {
if (data.children) { if (data.children) {
var isExpanded = self.nodeIsExpanded[keyPath] var isExpanded = self.nodeIsExpanded[keyPath]
var list = yo`<ul class=${css.ul_tv}>${children}</ul>` var list = yo`<ul class=${css.ul_tv}>${children}</ul>`
this.nodes[keyPath] = list
list.style.display = isExpanded !== undefined ? (isExpanded ? 'block' : 'none') : (expand ? 'block' : 'none') list.style.display = isExpanded !== undefined ? (isExpanded ? 'block' : 'none') : (expand ? 'block' : 'none')
caret.className = list.style.display === 'none' ? 'fa fa-caret-right' : 'fa fa-caret-down' caret.className = list.style.display === 'none' ? 'fa fa-caret-right' : 'fa fa-caret-down'
label.onclick = function () { label.onclick = function () {
...@@ -101,6 +103,10 @@ class TreeView { ...@@ -101,6 +103,10 @@ class TreeView {
return li return li
} }
nodeAt (path) {
return this.nodes[path]
}
formatSelfDefault (key, data) { formatSelfDefault (key, data) {
return yo`<label>${key}: ${data.self}</label>` return yo`<label>${key}: ${data.self}</label>`
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment