Sorting of "folders" before leafs
This commit is contained in:
parent
2f27aeffb3
commit
cc69f7194e
3 changed files with 42 additions and 8 deletions
|
|
@ -91,7 +91,11 @@ export class N2Tree extends CustomHTMLElement {
|
|||
}
|
||||
_mbus.dispatch('TREE_TRUNK_FETCHED')
|
||||
})
|
||||
.catch(e => { console.log(e); console.log(e.type, e.error); alert(e.error) })
|
||||
.catch(e => {
|
||||
console.error(e)
|
||||
console.log(e.type, e.error)
|
||||
alert(e.error)
|
||||
})
|
||||
}//}}}
|
||||
getNodeExpanded(UUID) {//{{{
|
||||
if (this.expandedNodes[UUID] === undefined)
|
||||
|
|
@ -396,7 +400,7 @@ export class N2TreeNode extends CustomHTMLElement {
|
|||
this.render(true)
|
||||
})
|
||||
|
||||
_mbus.subscribe(`NODE_EXPAND_${node.UUID}`, state => {
|
||||
_mbus.subscribe(`NODE_EXPAND_${node.UUID}`, _state => {
|
||||
this.render(true)
|
||||
})
|
||||
|
||||
|
|
@ -412,7 +416,7 @@ export class N2TreeNode extends CustomHTMLElement {
|
|||
return this
|
||||
|
||||
// Fetch the next level of children if the parent tree node is expanded and our children thus will be visible.
|
||||
const expanded = this.node.Children.length > 0 && this.tree.getNodeExpanded(this.node.UUID)
|
||||
const expanded = this.node.hasChildren() && this.tree.getNodeExpanded(this.node.UUID)
|
||||
|
||||
if (!this.children_populated && this.tree.getNodeExpanded(this.parent?.node.UUID)) {
|
||||
this.node.fetchChildren().then(() => this.children_populated = true)
|
||||
|
|
@ -435,7 +439,7 @@ export class N2TreeNode extends CustomHTMLElement {
|
|||
}
|
||||
|
||||
// The expand icon <img> is only changed to not get a flickering when re-rendering.
|
||||
if (this.node.Children.length === 0)
|
||||
if (!this.node.hasChildren())
|
||||
this.setImgSrc(this.elExpand, `/images/${window._VERSION}/leaf.svg`)
|
||||
else if (this.tree.getNodeExpanded(this.node.UUID))
|
||||
this.setImgSrc(this.elExpand, `/images/${window._VERSION}/expanded.svg`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue