final changes from PR comments

This commit is contained in:
Jamie Vigliotta
2020-07-24 10:11:46 -07:00
parent 68eb5e6286
commit 26069dac79
2 changed files with 19 additions and 11 deletions

View File

@ -85,13 +85,11 @@ export default {
item.key = this.openmct.objects.makeKeyString(domainObject.identifier); item.key = this.openmct.objects.makeKeyString(domainObject.identifier);
this.items.push(item); this.items.push(item);
// this.checkForUnits();
}, },
removeItem(identifier) { removeItem(identifier) {
let index = this.items.findIndex(item => this.openmct.objects.makeKeyString(identifier) === item.key); let index = this.items.findIndex(item => this.openmct.objects.makeKeyString(identifier) === item.key);
this.items.splice(index, 1); this.items.splice(index, 1);
// this.checkForUnits();
}, },
reorder(reorderPlan) { reorder(reorderPlan) {
let oldItems = this.items.slice(); let oldItems = this.items.slice();

View File

@ -65,8 +65,25 @@ export default {
return { return {
primaryTelemetryObjects: [], primaryTelemetryObjects: [],
secondaryTelemetryObjects: {}, secondaryTelemetryObjects: {},
compositions: [], compositions: []
hasUnits: false }
},
computed: {
hasUnits() {
for(let telemetryObject in this.secondaryTelemetryObjects) {
if(this.secondaryTelemetryObjects[telemetryObject]) {
let objects = this.secondaryTelemetryObjects[telemetryObject];
for(let current of objects) {
let metadata = this.openmct.telemetry.getMetadata(current.domainObject);
for(let metadatum of metadata.valueMetadatas) {
if(metadatum.unit) {
return true;
}
}
}
}
}
return false;
} }
}, },
mounted() { mounted() {
@ -111,7 +128,6 @@ export default {
this.$set(this.secondaryTelemetryObjects, primary.key, undefined); this.$set(this.secondaryTelemetryObjects, primary.key, undefined);
this.primaryTelemetryObjects.splice(index,1); this.primaryTelemetryObjects.splice(index,1);
primary = undefined; primary = undefined;
this.checkForUnits();
}, },
reorderPrimary(reorderPlan) { reorderPrimary(reorderPlan) {
let oldComposition = this.primaryTelemetryObjects.slice(); let oldComposition = this.primaryTelemetryObjects.slice();
@ -129,9 +145,6 @@ export default {
array.push(secondary); array.push(secondary);
this.$set(this.secondaryTelemetryObjects, primary.key, array); this.$set(this.secondaryTelemetryObjects, primary.key, array);
if(!this.hasUnits) {
this.checkForUnits(domainObject);
}
} }
}, },
removeSecondary(primary) { removeSecondary(primary) {
@ -142,9 +155,6 @@ export default {
array.splice(index, 1); array.splice(index, 1);
this.$set(this.secondaryTelemetryObjects, primary.key, array); this.$set(this.secondaryTelemetryObjects, primary.key, array);
if(this.hasUnits) {
this.checkForUnits();
}
} }
}, },
checkForUnits() { checkForUnits() {