Commit af235c86 authored by yann300's avatar yann300

add isExpanded && updateNode function

parent 8746cf79
...@@ -105,6 +105,14 @@ class TreeView { ...@@ -105,6 +105,14 @@ class TreeView {
return li return li
} }
isExpanded (path) {
var current = this.nodeAt(path)
if (current) {
return current.style.display !== 'none'
}
return false
}
expand (path) { expand (path) {
if (this.labels[path]) { if (this.labels[path]) {
this.carets[path].className = this.carets[path].className === 'fa fa-caret-right' ? 'fa fa-caret-down' : 'fa fa-caret-right' this.carets[path].className = this.carets[path].className === 'fa fa-caret-right' ? 'fa fa-caret-down' : 'fa fa-caret-right'
...@@ -117,6 +125,17 @@ class TreeView { ...@@ -117,6 +125,17 @@ class TreeView {
return this.nodes[path] return this.nodes[path]
} }
updateNode (path, newNode) {
var current = this.nodeAt(path)
if (current) {
var parent = current.parentNode
if (parent) {
parent.replaceChild(newNode, current)
this.nodes[path] = newNode
}
}
}
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