diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/App.vue | 30 | ||||
| -rw-r--r-- | src/layout.ts | 5 |
2 files changed, 22 insertions, 13 deletions
diff --git a/src/App.vue b/src/App.vue index f138b21..5c7bbf2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -891,7 +891,7 @@ export default defineComponent({ // Query server let urlParams = new URLSearchParams({type: 'node', tree: this.uiOpts.tree}); if (nodeName != null){ - urlParams.append('name', encodeURIComponent(nodeName)); + urlParams.append('name', nodeName); urlParams.append('toroot', 'true'); } let responseObj: {[x: string]: TolNode} = await this.loadFromServer(urlParams); @@ -914,9 +914,24 @@ export default defineComponent({ // Initialise tree this.tolMap.clear(); nodeNames.forEach(n => {this.tolMap.set(n, responseObj[n])}); - this.layoutTree = initLayoutTree(this.tolMap, rootName, 0); - this.activeRoot = this.layoutTree; - this.layoutMap = initLayoutMap(this.layoutTree); + if (nodeName == null){ + this.layoutTree = initLayoutTree(this.tolMap, rootName, 0); + this.layoutMap = initLayoutMap(this.layoutTree); + this.activeRoot = this.layoutTree; + } else { + this.layoutTree = initLayoutTree(this.tolMap, rootName, -1); + this.layoutMap = initLayoutMap(this.layoutTree); + // Set active root + let targetNode = this.layoutMap.get(nodeName)!; + let newRoot = targetNode.parent == null ? targetNode : targetNode.parent; + LayoutNode.hideUpward(newRoot, this.layoutMap); + if (targetNode.parent != null){ // Account for ancestry-bar transition + this.ancestryBarInTransition = true; + this.relayoutDuringAncestryBarTransition(); + } + this.activeRoot = newRoot; + setTimeout(() => this.setLastFocused(targetNode!), this.uiOpts.transitionDuration); + } // Skip initial transition if (firstInit){ this.justInitialised = true; @@ -925,13 +940,6 @@ export default defineComponent({ // Relayout await this.updateAreaDims(); this.relayoutWithCollapse(false); - // Possibly jump to a target node - if (nodeName != null){ - let oldSetting = this.uiOpts.searchJumpMode; - this.uiOpts.searchJumpMode = true; - await this.onSearch(nodeName); - this.uiOpts.searchJumpMode = oldSetting; - } }, async reInit(){ if (this.activeRoot != this.layoutTree){ diff --git a/src/layout.ts b/src/layout.ts index 665c617..ec5b70c 100644 --- a/src/layout.ts +++ b/src/layout.ts @@ -221,7 +221,7 @@ function removeFromLayoutMap(node: LayoutNode, map: LayoutMap): void { node.children.forEach(n => removeFromLayoutMap(n, map)); } -// Creates a LayoutNode representing a TolNode tree, up to a given depth (0 means just the root) +// Creates a LayoutNode representing a TolNode tree, up to a given depth (0 means just the root, -1 means no limit) export function initLayoutTree(tolMap: TolMap, rootName: string, depth: number): LayoutNode { function initHelper(tolMap: TolMap, nodeName: string, depthLeft: number, atDepth: number = 0): LayoutNode { if (depthLeft == 0){ @@ -233,7 +233,8 @@ export function initLayoutTree(tolMap: TolMap, rootName: string, depth: number): if (childNames.length == 0 || !tolMap.has(childNames[0])){ return new LayoutNode(nodeName, []); } else { - let children = childNames.map((name: string) => initHelper(tolMap, name, depthLeft-1, atDepth+1)); + let children = childNames.map((name: string) => + initHelper(tolMap, name, depthLeft != -1 ? depthLeft-1 : -1, atDepth+1)); let node = new LayoutNode(nodeName, children); children.forEach(n => n.parent = node); return node; |
