Fixes isMutable error when domainobject is undefined (#3690)

* fix isMutable error when domainobject is undefined

Co-authored-by: Deep Tailor <deep.j.tailor@nasa.com>
Co-authored-by: Shefali Joshi <simplyrender@gmail.com>
Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
Deep Tailor
2021-02-23 16:51:50 -08:00
committed by GitHub
parent fc59a4dce4
commit f789775b1c
2 changed files with 18 additions and 6 deletions

View File

@ -109,7 +109,8 @@ export default {
data() { data() {
return { return {
domainObject: undefined, domainObject: undefined,
currentObjectPath: [] currentObjectPath: [],
mutablePromise: undefined
}; };
}, },
watch: { watch: {
@ -130,7 +131,7 @@ export default {
}, },
mounted() { mounted() {
if (this.openmct.objects.supportsMutation(this.item.identifier)) { if (this.openmct.objects.supportsMutation(this.item.identifier)) {
this.openmct.objects.getMutable(this.item.identifier) this.mutablePromise = this.openmct.objects.getMutable(this.item.identifier)
.then(this.setObject); .then(this.setObject);
} else { } else {
this.openmct.objects.get(this.item.identifier) this.openmct.objects.get(this.item.identifier)
@ -142,13 +143,18 @@ export default {
this.removeSelectable(); this.removeSelectable();
} }
if (this.domainObject.isMutable) { if (this.mutablePromise) {
this.mutablePromise.then(() => {
this.openmct.objects.destroyMutable(this.domainObject);
});
} else {
this.openmct.objects.destroyMutable(this.domainObject); this.openmct.objects.destroyMutable(this.domainObject);
} }
}, },
methods: { methods: {
setObject(domainObject) { setObject(domainObject) {
this.domainObject = domainObject; this.domainObject = domainObject;
this.mutablePromise = undefined;
this.currentObjectPath = [this.domainObject].concat(this.objectPath.slice()); this.currentObjectPath = [this.domainObject].concat(this.objectPath.slice());
this.$nextTick(() => { this.$nextTick(() => {
let reference = this.$refs.objectFrame; let reference = this.$refs.objectFrame;

View File

@ -131,7 +131,8 @@ export default {
domainObject: undefined, domainObject: undefined,
formats: undefined, formats: undefined,
viewKey: `alphanumeric-format-${Math.random()}`, viewKey: `alphanumeric-format-${Math.random()}`,
status: '' status: '',
mutablePromise: undefined
}; };
}, },
computed: { computed: {
@ -213,7 +214,7 @@ export default {
}, },
mounted() { mounted() {
if (this.openmct.objects.supportsMutation(this.item.identifier)) { if (this.openmct.objects.supportsMutation(this.item.identifier)) {
this.openmct.objects.getMutable(this.item.identifier) this.mutablePromise = this.openmct.objects.getMutable(this.item.identifier)
.then(this.setObject); .then(this.setObject);
} else { } else {
this.openmct.objects.get(this.item.identifier) this.openmct.objects.get(this.item.identifier)
@ -235,7 +236,11 @@ export default {
this.openmct.time.off("bounds", this.refreshData); this.openmct.time.off("bounds", this.refreshData);
if (this.domainObject.isMutable) { if (this.mutablePromise) {
this.mutablePromise.then(() => {
this.openmct.objects.destroyMutable(this.domainObject);
});
} else {
this.openmct.objects.destroyMutable(this.domainObject); this.openmct.objects.destroyMutable(this.domainObject);
} }
}, },
@ -296,6 +301,7 @@ export default {
}, },
setObject(domainObject) { setObject(domainObject) {
this.domainObject = domainObject; this.domainObject = domainObject;
this.mutablePromise = undefined;
this.keyString = this.openmct.objects.makeKeyString(domainObject.identifier); this.keyString = this.openmct.objects.makeKeyString(domainObject.identifier);
this.metadata = this.openmct.telemetry.getMetadata(this.domainObject); this.metadata = this.openmct.telemetry.getMetadata(this.domainObject);
this.limitEvaluator = this.openmct.telemetry.limitEvaluator(this.domainObject); this.limitEvaluator = this.openmct.telemetry.limitEvaluator(this.domainObject);