mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 14:07:50 +00:00
Splits the parent and child navigationPaths into arrays of keystrings and then checks to ensure that every keystring in the parent path is included in the child path in order
This commit is contained in:
parent
e4657f79cd
commit
0b24c4f2c5
@ -355,17 +355,18 @@ export default {
|
|||||||
this.abortItemLoad(path);
|
this.abortItemLoad(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
let pathIndex = this.openTreeItems.indexOf(path);
|
const pathIndex = this.openTreeItems.indexOf(path);
|
||||||
|
|
||||||
if (pathIndex === -1) {
|
if (pathIndex === -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.treeItems = this.treeItems.filter((checkItem) => {
|
this.treeItems = this.treeItems.filter((item) => {
|
||||||
if (checkItem.navigationPath !== path
|
const otherPath = item.navigationPath;
|
||||||
&& checkItem.navigationPath.includes(path)) {
|
if (otherPath !== path
|
||||||
this.destroyObserverByPath(checkItem.navigationPath);
|
&& this.isTreeItemAChildOf(otherPath, path)) {
|
||||||
this.destroyMutableByPath(checkItem.navigationPath);
|
this.destroyObserverByPath(otherPath);
|
||||||
|
this.destroyMutableByPath(otherPath);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -960,6 +961,24 @@ export default {
|
|||||||
isTreeItemPathOpen(path) {
|
isTreeItemPathOpen(path) {
|
||||||
return this.openTreeItems.includes(path);
|
return this.openTreeItems.includes(path);
|
||||||
},
|
},
|
||||||
|
isTreeItemAChildOf(childNavigationPath, parentNavigationPath) {
|
||||||
|
const childPathKeys = childNavigationPath.split('/');
|
||||||
|
const parentPathKeys = parentNavigationPath.split('/');
|
||||||
|
|
||||||
|
// If child path is shorter than or same length as
|
||||||
|
// the parent path, then it's not a child.
|
||||||
|
if (childPathKeys.length <= parentPathKeys.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < parentPathKeys.length; i++) {
|
||||||
|
if (childPathKeys[i] !== parentPathKeys[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
getElementStyleValue(el, style) {
|
getElementStyleValue(el, style) {
|
||||||
if (!el) {
|
if (!el) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user