[Navigation Tree] Simplify logic (#3474)

* added new navigation method for tracking, lots of optimizations

* updated indicator logic, tweaked objectPath/navigationPath, removed old code

* added temporary ancestors variable to be used while building new tree ui during navigation

* removed observer for ancestors, all handled in composition watch now

* updates from PR comments

* fixing testing errors

* checking for older format of saved path, update if old
This commit is contained in:
Jamie V
2020-10-29 11:58:45 -07:00
committed by GitHub
parent 0e6ce7f58b
commit 5646a252f7
3 changed files with 451 additions and 429 deletions

View File

@@ -26,6 +26,10 @@
overflow: hidden; overflow: hidden;
transition: all; transition: all;
.c-tree__item-h {
width: 100%;
}
&__scrollable-children { &__scrollable-children {
overflow: auto; overflow: auto;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
<template> <template>
<li <div
ref="me" ref="me"
:style="{ :style="{
'top': virtualScroll ? itemTop : 'auto', 'top': virtualScroll ? itemTop : 'auto',
@@ -24,7 +24,7 @@
<object-label <object-label
:domain-object="node.object" :domain-object="node.object"
:object-path="node.objectPath" :object-path="node.objectPath"
:navigate-to-path="navigateToPath" :navigate-to-path="navigationPath"
:style="{ paddingLeft: leftOffset }" :style="{ paddingLeft: leftOffset }"
/> />
<view-control <view-control
@@ -34,7 +34,7 @@
:enabled="hasComposition && showDown" :enabled="hasComposition && showDown"
/> />
</div> </div>
</li> </div>
</template> </template>
<script> <script>
@@ -83,18 +83,14 @@ export default {
virtualScroll: { virtualScroll: {
type: Boolean, type: Boolean,
default: false default: false
},
shouldEmitHeight: {
type: Boolean,
default: false
} }
}, },
data() { data() {
this.navigateToPath = this.buildPathString(this.node.navigateToParent); this.navigationPath = this.node.navigationPath;
return { return {
hasComposition: false, hasComposition: false,
navigated: this.navigateToPath === this.openmct.router.currentLocation.path, navigated: this.isNavigated(),
expanded: false expanded: false
}; };
}, },
@@ -122,9 +118,6 @@ export default {
mounted() { mounted() {
let objectComposition = this.openmct.composition.get(this.node.object); let objectComposition = this.openmct.composition.get(this.node.object);
// only reliable way to get final item height
this.readyStateCheck();
this.domainObject = this.node.object; this.domainObject = this.node.object;
let removeListener = this.openmct.objects.observe(this.domainObject, '*', (newObject) => { let removeListener = this.openmct.objects.observe(this.domainObject, '*', (newObject) => {
this.domainObject = newObject; this.domainObject = newObject;
@@ -139,30 +132,13 @@ export default {
}, },
destroyed() { destroyed() {
this.openmct.router.off('change:path', this.highlightIfNavigated); this.openmct.router.off('change:path', this.highlightIfNavigated);
document.removeEventListener('readystatechange', this.emitHeight);
}, },
methods: { methods: {
readyStateCheck() { isNavigated() {
if (document.readyState !== 'complete') { return this.navigationPath === this.openmct.router.currentLocation.path;
document.addEventListener('readystatechange', this.emitHeight);
} else {
this.emitHeight();
}
}, },
emitHeight() { highlightIfNavigated() {
if (this.shouldEmitHeight && document.readyState === 'complete') { this.navigated = this.isNavigated();
this.$emit('emittedHeight', this.$el.offsetHeight);
}
},
buildPathString(parentPath) {
return [parentPath, this.openmct.objects.makeKeyString(this.node.object.identifier)].join('/');
},
highlightIfNavigated(newPath, oldPath) {
if (newPath === this.navigateToPath) {
this.navigated = true;
} else if (oldPath === this.navigateToPath) {
this.navigated = false;
}
}, },
resetTreeHere() { resetTreeHere() {
this.$emit('resetTree', this.node); this.$emit('resetTree', this.node);