mirror of
https://github.com/nasa/openmct.git
synced 2025-04-12 05:40:17 +00:00
improve tab loading logic and fix delete tab issue (#3671)
This commit is contained in:
parent
e4d6e90c35
commit
5e2fe7dc42
@ -53,7 +53,7 @@
|
||||
:class="{'c-tabs-view__object-holder--hidden': !isCurrent(tab)}"
|
||||
>
|
||||
<object-view
|
||||
v-if="internalDomainObject.keep_alive ? currentTab : isCurrent(tab)"
|
||||
v-if="isTabLoaded(tab)"
|
||||
class="c-tabs-view__object"
|
||||
:default-object="tab.domainObject"
|
||||
:object-path="tab.objectPath"
|
||||
@ -100,7 +100,8 @@ export default {
|
||||
setCurrentTab: true,
|
||||
isDragging: false,
|
||||
allowDrop: false,
|
||||
searchTabKey: `tabs.pos.${keyString}`
|
||||
searchTabKey: `tabs.pos.${keyString}`,
|
||||
loadedTabs: {}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@ -151,9 +152,12 @@ export default {
|
||||
document.removeEventListener('dragend', this.dragend);
|
||||
},
|
||||
methods: {
|
||||
addTabToLoaded(tab) {
|
||||
this.loadedTabs[tab.keyString] = true;
|
||||
},
|
||||
setCurrentTabByIndex(index) {
|
||||
if (this.tabsList[index]) {
|
||||
this.currentTab = this.tabsList[index];
|
||||
this.showTab(this.tabsList[index]);
|
||||
}
|
||||
},
|
||||
showTab(tab, index) {
|
||||
@ -162,6 +166,7 @@ export default {
|
||||
}
|
||||
|
||||
this.currentTab = tab;
|
||||
this.addTabToLoaded(tab);
|
||||
},
|
||||
showRemoveDialog(index) {
|
||||
if (!this.tabsList[index]) {
|
||||
@ -179,7 +184,7 @@ export default {
|
||||
label: 'Ok',
|
||||
emphasis: 'true',
|
||||
callback: () => {
|
||||
this.removeFromComposition(childDomainObject);
|
||||
this.composition.remove(childDomainObject);
|
||||
prompt.dismiss();
|
||||
}
|
||||
},
|
||||
@ -192,9 +197,6 @@ export default {
|
||||
]
|
||||
});
|
||||
},
|
||||
removeFromComposition(childDomainObject) {
|
||||
this.composition.remove(childDomainObject);
|
||||
},
|
||||
addItem(domainObject) {
|
||||
let type = this.openmct.types.get(domainObject.type) || unknownObjectType;
|
||||
let keyString = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||
@ -215,7 +217,7 @@ export default {
|
||||
this.tabsList.push(tabItem);
|
||||
|
||||
if (this.setCurrentTab) {
|
||||
this.currentTab = tabItem;
|
||||
this.showTab(tabItem);
|
||||
this.setCurrentTab = false;
|
||||
}
|
||||
},
|
||||
@ -224,15 +226,21 @@ export default {
|
||||
this.setCurrentTab = true;
|
||||
},
|
||||
removeItem(identifier) {
|
||||
let pos = this.tabsList.findIndex(tab =>
|
||||
tab.domainObject.identifier.namespace === identifier.namespace && tab.domainObject.identifier.keyString === identifier.keyString
|
||||
);
|
||||
let keyStringToBeRemoved = this.openmct.objects.makeKeyString(identifier);
|
||||
|
||||
let pos = this.tabsList.findIndex(tab => {
|
||||
return tab.keyString === keyStringToBeRemoved;
|
||||
});
|
||||
|
||||
let tabToBeRemoved = this.tabsList[pos];
|
||||
|
||||
tabToBeRemoved.statusUnsubscribe();
|
||||
|
||||
this.tabsList.splice(pos, 1);
|
||||
|
||||
this.loadedTabs[keyStringToBeRemoved] = undefined;
|
||||
delete this.loadedTabs[keyStringToBeRemoved];
|
||||
|
||||
if (this.isCurrent(tabToBeRemoved)) {
|
||||
this.showTab(this.tabsList[this.tabsList.length - 1], this.tabsList.length - 1);
|
||||
}
|
||||
@ -291,10 +299,15 @@ export default {
|
||||
let tabPos = this.tabsList.findIndex((tab) => {
|
||||
return tab.keyString === keyString;
|
||||
});
|
||||
let tab = this.tabsList[tabPos];
|
||||
|
||||
if (tabPos !== -1) {
|
||||
let tab = this.tabsList[tabPos];
|
||||
this.$set(tab, 'status', status);
|
||||
this.$set(tab, 'status', status);
|
||||
},
|
||||
isTabLoaded(tab) {
|
||||
if (this.internalDomainObject.keep_alive) {
|
||||
return true;
|
||||
} else {
|
||||
return this.loadedTabs[tab.keyString];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ define([
|
||||
form: [
|
||||
{
|
||||
"key": "keep_alive",
|
||||
"name": "Keep Tabs Alive",
|
||||
"name": "Eager Load Tabs",
|
||||
"control": "select",
|
||||
"options": [
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user