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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View File

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

View File

@ -131,7 +131,8 @@ export default {
domainObject: undefined,
formats: undefined,
viewKey: `alphanumeric-format-${Math.random()}`,
status: ''
status: '',
mutablePromise: undefined
};
},
computed: {
@ -213,7 +214,7 @@ export default {
},
mounted() {
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);
} else {
this.openmct.objects.get(this.item.identifier)
@ -235,7 +236,11 @@ export default {
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);
}
},
@ -296,6 +301,7 @@ export default {
},
setObject(domainObject) {
this.domainObject = domainObject;
this.mutablePromise = undefined;
this.keyString = this.openmct.objects.makeKeyString(domainObject.identifier);
this.metadata = this.openmct.telemetry.getMetadata(this.domainObject);
this.limitEvaluator = this.openmct.telemetry.limitEvaluator(this.domainObject);