Merge pull request #3255 from nasa/ladtableset-name-clarity

Ladtableset naming clarity
This commit is contained in:
Jamie V 2020-09-14 12:56:59 -07:00 committed by GitHub
commit 24c5dc03de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 45 deletions

View File

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

View File

@ -145,7 +145,6 @@ export default {
}, },
unit() { unit() {
let value = this.item.value; let value = this.item.value;
let unit = this.metadata.value(value).unit; let unit = this.metadata.value(value).unit;
return unit; return unit;