Schema expansion

This commit is contained in:
Magnus Åhall 2025-07-07 20:29:15 +02:00
parent d450418bf6
commit c3f8bedea1
3 changed files with 39 additions and 11 deletions

View file

@ -19,7 +19,6 @@ export class App {
'NODE_DELETE',
'NODE_EDIT_NAME',
'NODE_MOVE',
'NODE_REMOVED',
'NODE_SELECTED',
'TREE_RELOAD_NODE',
'TYPES_LIST_FETCHED',
@ -63,13 +62,6 @@ export class App {
this.nodesMove(nodes, this.currentNode.ID)
break
case 'NODE_REMOVED':
// Event dispatched when a tree node is removed after an update.
if (this.currentNode.ID !== event.detail)
return
mbus.dispatch('NODE_SELECTED', null)
break
case 'EDITOR_NODE_SAVE':
this.nodeUpdate()
break
@ -269,6 +261,7 @@ export class App {
}
this.tree.updateNode(parseInt(parentID))
mbus.dispatch('NODE_SELECTED', null)
})
.catch(err => showError(err))
}// }}}
@ -552,7 +545,11 @@ export class TreeNode {
this.children = null
this.nameElement = null
this.expandEventListenerAdded = false
this.expanded = false
this.expanded = this.retrieveExpanded()
if (this.expanded)
this.tree.fetchNodes(this.node.ID)
.then(()=>this.render())
}// }}}
render() {// {{{
if (this.element === null) {
@ -633,6 +630,7 @@ export class TreeNode {
else
this.expanded = expanded
this.storeExpanded()
this.updateExpandImages()
if (!this.childrenFetched && this.node.NumChildren > 0 && this.node.Children.length == 0) {
@ -652,6 +650,13 @@ export class TreeNode {
.catch(err => reject(err))
})
}// }}}
storeExpanded() {// {{{
sessionStorage.setItem(`tree_expand_${this.node.ID}`, this.expanded ? '1' : '0')
}// }}}
retrieveExpanded() {// {{{
return sessionStorage.getItem(`tree_expand_${this.node.ID}`) === '1'
}// }}}
}
export class TypesList {