renamed methods and variables for clarity

This commit is contained in:
Jamie Vigliotta 2020-07-31 11:48:23 -07:00
parent 0d478d5dfc
commit 66bb938fc4

View File

@ -32,20 +32,20 @@
</thead>
<tbody>
<template
v-for="primary in primaryTelemetryObjects"
v-for="ladTable in ladTableObjects"
>
<tr
:key="primary.key"
:key="ladTable.key"
class="c-table__group-header js-lad-table-set__table-headers"
>
<td colspan="10">
{{ primary.domainObject.name }}
{{ ladTable.domainObject.name }}
</td>
</tr>
<lad-row
v-for="secondary in secondaryTelemetryObjects[primary.key]"
:key="secondary.key"
:domain-object="secondary.domainObject"
v-for="telemetryObject in ladTelemetryObjects[ladTable.key]"
:key="telemetryObject.key"
:domain-object="telemetryObject.domainObject"
:has-units="hasUnits"
/>
</template>
@ -63,16 +63,16 @@ export default {
},
data() {
return {
primaryTelemetryObjects: [],
secondaryTelemetryObjects: {},
ladTableObjects: [],
ladTelemetryObjects: {},
compositions: []
}
},
computed: {
hasUnits() {
let ladTables = Object.values(this.secondaryTelemetryObjects);
for(let ladTable of ladTables) {
for(let telemetryObject of ladTable) {
let telemetryObjects = Object.values(this.ladTelemetryObjects);
for(let telemtryObjectsByKey of telemetryObjects) {
for(let telemetryObject of telemtryObjectsByKey) {
let metadata = this.openmct.telemetry.getMetadata(telemetryObject.domainObject);
for(let metadatum of metadata.valueMetadatas) {
if(metadatum.unit) {
@ -86,32 +86,32 @@ export default {
},
mounted() {
this.composition = this.openmct.composition.get(this.domainObject);
this.composition.on('add', this.addPrimary);
this.composition.on('remove', this.removePrimary);
this.composition.on('reorder', this.reorderPrimary);
this.composition.on('add', this.addLadTable);
this.composition.on('remove', this.removeLadTable);
this.composition.on('reorder', this.reorderLadTables);
this.composition.load();
},
destroyed() {
this.composition.off('add', this.addPrimary);
this.composition.off('remove', this.removePrimary);
this.composition.off('reorder', this.reorderPrimary);
this.composition.off('add', this.addLadTable);
this.composition.off('remove', this.removeLadTable);
this.composition.off('reorder', this.reorderLadTables);
this.compositions.forEach(c => {
c.composition.off('add', c.addCallback);
c.composition.off('remove', c.removeCallback);
});
},
methods: {
addPrimary(domainObject) {
let primary = {};
primary.domainObject = domainObject;
primary.key = this.openmct.objects.makeKeyString(domainObject.identifier);
addLadTable(domainObject) {
let ladTable = {};
ladTable.domainObject = domainObject;
ladTable.key = this.openmct.objects.makeKeyString(domainObject.identifier);
this.$set(this.secondaryTelemetryObjects, primary.key, []);
this.primaryTelemetryObjects.push(primary);
this.$set(this.ladTelemetryObjects, ladTable.key, []);
this.ladTableObjects.push(ladTable);
let composition = this.openmct.composition.get(primary.domainObject),
addCallback = this.addSecondary(primary),
removeCallback = this.removeSecondary(primary);
let composition = this.openmct.composition.get(ladTable.domainObject),
addCallback = this.addTelemetryObject(ladTable),
removeCallback = this.removeTelemetryObject(ladTable);
composition.on('add', addCallback);
composition.on('remove', removeCallback);
@ -119,39 +119,39 @@ export default {
this.compositions.push({composition, addCallback, removeCallback});
},
removePrimary(identifier) {
let index = this.primaryTelemetryObjects.findIndex(primary => this.openmct.objects.makeKeyString(identifier) === primary.key),
primary = this.primaryTelemetryObjects[index];
removeLadTable(identifier) {
let index = this.ladTableObjects.findIndex(ladTable => this.openmct.objects.makeKeyString(identifier) === ladTable.key);
let ladTable = this.ladTableObjects[index];
this.$delete(this.secondaryTelemetryObjects, primary.key);
this.primaryTelemetryObjects.splice(index,1);
this.$delete(this.ladTelemetryObjects, ladTable.key);
this.ladTableObjects.splice(index,1);
},
reorderPrimary(reorderPlan) {
let oldComposition = this.primaryTelemetryObjects.slice();
reorderLadTables(reorderPlan) {
let oldComposition = this.ladTableObjects.slice();
reorderPlan.forEach(reorderEvent => {
this.$set(this.primaryTelemetryObjects, reorderEvent.newIndex, oldComposition[reorderEvent.oldIndex]);
this.$set(this.ladTableObjects, reorderEvent.newIndex, oldComposition[reorderEvent.oldIndex]);
});
},
addSecondary(primary) {
addTelemetryObject(ladTable) {
return (domainObject) => {
let secondary = {};
secondary.key = this.openmct.objects.makeKeyString(domainObject.identifier);
secondary.domainObject = domainObject;
let telemetryObject = {};
telemetryObject.key = this.openmct.objects.makeKeyString(domainObject.identifier);
telemetryObject.domainObject = domainObject;
let array = this.secondaryTelemetryObjects[primary.key];
array.push(secondary);
let array = this.ladTelemetryObjects[ladTable.key];
array.push(telemetryObject);
this.$set(this.secondaryTelemetryObjects, primary.key, array);
this.$set(this.ladTelemetryObjects, ladTable.key, array);
}
},
removeSecondary(primary) {
removeTelemetryObject(ladTable) {
return (identifier) => {
let array = this.secondaryTelemetryObjects[primary.key],
index = array.findIndex(secondary => this.openmct.objects.makeKeyString(identifier) === secondary.key);
let telemetryObjects = this.ladTelemetryObjects[ladTable.key];
let index = telemetryObjects.findIndex(telemetryObject => this.openmct.objects.makeKeyString(identifier) === telemetryObject.key);
array.splice(index, 1);
telemetryObjects.splice(index, 1);
this.$set(this.secondaryTelemetryObjects, primary.key, array);
this.$set(this.ladTelemetryObjects, ladTable.key, telemetryObjects);
}
}
}