Pass objectPath as property to LAD rows (#3870)

Includes some code cleanup
This commit is contained in:
Andrew Henry 2021-05-11 18:58:17 -07:00 committed by GitHub
parent 12416b8079
commit 3ca133c782
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 16 deletions

View File

@ -43,12 +43,16 @@ export default function LADTableSetViewProvider(openmct) {
components: {
LadTableSet: LadTableSet
},
data() {
return {
domainObject
};
},
provide: {
openmct,
domainObject,
objectPath
},
template: '<lad-table-set></lad-table-set>'
template: '<lad-table-set :domain-object="domainObject"></lad-table-set>'
});
},
destroy: function (element) {

View File

@ -56,7 +56,7 @@ export default {
type: Object,
required: true
},
objectPath: {
pathToTable: {
type: Array,
required: true
},
@ -66,20 +66,19 @@ export default {
}
},
data() {
let currentObjectPath = this.objectPath.slice();
currentObjectPath.unshift(this.domainObject);
return {
timestamp: undefined,
value: '---',
valueClass: '',
currentObjectPath,
unit: ''
};
},
computed: {
formattedTimestamp() {
return this.timestamp !== undefined ? this.getFormattedTimestamp(this.timestamp) : '---';
},
objectPath() {
return [this.domainObject, ...this.pathToTable];
}
},
mounted() {
@ -182,7 +181,7 @@ export default {
};
},
showContextMenu(event) {
let actionCollection = this.openmct.actions.get(this.currentObjectPath, this.getView());
let actionCollection = this.openmct.actions.get(this.objectPath, this.getView());
let allActions = actionCollection.getActionsObject();
let applicableActions = CONTEXT_MENU_ACTIONS.map(key => allActions[key]);

View File

@ -33,10 +33,10 @@
</thead>
<tbody>
<lad-row
v-for="item in items"
:key="item.key"
:domain-object="item.domainObject"
:object-path="objectPath"
v-for="ladRow in items"
:key="ladRow.key"
:domain-object="ladRow.domainObject"
:path-to-table="objectPath"
:has-units="hasUnits"
/>
</tbody>

View File

@ -43,9 +43,10 @@
</td>
</tr>
<lad-row
v-for="telemetryObject in ladTelemetryObjects[ladTable.key]"
:key="telemetryObject.key"
:domain-object="telemetryObject.domainObject"
v-for="ladRow in ladTelemetryObjects[ladTable.key]"
:key="ladRow.key"
:domain-object="ladRow.domainObject"
:path-to-table="ladTable.objectPath"
:has-units="hasUnits"
/>
</template>
@ -60,7 +61,13 @@ export default {
components: {
LadRow
},
inject: ['openmct', 'domainObject'],
inject: ['openmct', 'objectPath'],
props: {
domainObject: {
type: Object,
required: true
}
},
data() {
return {
ladTableObjects: [],
@ -106,6 +113,7 @@ export default {
let ladTable = {};
ladTable.domainObject = domainObject;
ladTable.key = this.openmct.objects.makeKeyString(domainObject.identifier);
ladTable.objectPath = [domainObject, ...this.objectPath];
this.$set(this.ladTelemetryObjects, ladTable.key, []);
this.ladTableObjects.push(ladTable);