Root page override

This commit is contained in:
Magnus Åhall 2026-06-10 20:03:31 +02:00
parent 31eee4ede5
commit b3ca0d29d0
6 changed files with 70 additions and 29 deletions

View file

@ -16,26 +16,33 @@ export class App {
document.getElementById('tree-nodes')?.focus()
})
const mainPage = document.getElementById('main-page')
const determineNodePage = uuid => {
if (uuid == ROOT_NODE)
mainPage.classList.add('root-node-override')
else
mainPage.classList.remove('root-node-override')
}
_mbus.subscribe('TREE_RENDERED', async () => {
// Subscribing to the start node existing after the tree trunk is
// fetched since the NODE_COMPONENT_EXIST message isn't sent for the
// root node itself, and the root node should be selected in the tree
// after it is rendered when the site is shown without UUID in the URL.
const startNode = await this.getStartNode()
if (startNode.UUID == ROOT_NODE)
this.goToNode(startNode.UUID, false, false)
else
this.goToNode(startNode.UUID, false, false)
determineNodePage(startNode.UUID)
this.goToNode(startNode.UUID, false, false)
})
_mbus.subscribe('TREE_NODE_SELECTED', event => {
const node = event.detail.data
determineNodePage(node.UUID)
this.goToNode(node.UUID, false, false)
})
_mbus.subscribe('GO_TO_NODE', event => {
const node = event.detail.data
determineNodePage(node.nodeUUID)
this.goToNode(node.nodeUUID, node.dontPush, node.dontExpand)
})
@ -61,6 +68,8 @@ export class App {
document.getElementById('node-content')?.focus()
})
document.querySelector('#page-root .create').addEventListener('click', () => this.createNode())
_mbus.dispatch('SHOW_PAGE', { page: 'node' })
window._sync = new Sync()