diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-05-06 19:02:16 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-05-06 19:02:24 +1000 |
| commit | 2ab9a92a9d5ea192835229191c502a94d576a033 (patch) | |
| tree | 40f4f38066cd10c0df0ecb0e51e7e2795608a526 /src/App.vue | |
| parent | c2aeb45c9e5f6e849728fc6ac674d85759361962 (diff) | |
Fix lack server querying when click-holding leaves
Diffstat (limited to 'src/App.vue')
| -rw-r--r-- | src/App.vue | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/App.vue b/src/App.vue index 66ed577..c9d752d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -231,13 +231,31 @@ export default defineComponent({ console.log('Ignored expand-to-view on active-root node'); return; } - LayoutNode.hideUpward(layoutNode); - this.activeRoot = layoutNode; - tryLayout(this.activeRoot, this.tileAreaPos, this.tileAreaDims, this.lytOpts, { - allowCollapse: true, - chg: {type: 'expand', node: layoutNode, tolMap: this.tolMap}, - layoutMap: this.layoutMap - }); + // Function for expanding tile + let doExpansion = () => { + LayoutNode.hideUpward(layoutNode); + this.activeRoot = layoutNode; + tryLayout(this.activeRoot, this.tileAreaPos, this.tileAreaDims, this.lytOpts, { + allowCollapse: true, + chg: {type: 'expand', node: layoutNode, tolMap: this.tolMap}, + layoutMap: this.layoutMap + }); + }; + // Check if data for node-to-expand exists, getting from server if needed + let tolNode = this.tolMap.get(layoutNode.name)!; + if (!this.tolMap.has(tolNode.children[0])){ + return fetch('/data/node?name=' + encodeURIComponent(layoutNode.name)) + .then(response => response.json()) + .then(obj => { + Object.getOwnPropertyNames(obj).forEach(key => {this.tolMap.set(key, obj[key])}); + doExpansion(); + }) + .catch(error => { + console.log('ERROR loading tolnode data', error); + }); + } else { + return new Promise((resolve, reject) => resolve(doExpansion())); + } }, onNonleafClickHeld(layoutNode: LayoutNode){ if (layoutNode == this.activeRoot){ |
