From cc2df8401ba039b96fda66c4bf512f516b24608e Mon Sep 17 00:00:00 2001 From: Joel McKinnon Date: Tue, 17 Mar 2020 17:36:55 -0700 Subject: [PATCH] vue style render of description --- .../condition/components/Condition.vue | 95 ++++++++++++------- 1 file changed, 60 insertions(+), 35 deletions(-) diff --git a/src/plugins/condition/components/Condition.vue b/src/plugins/condition/components/Condition.vue index cd00052358..489b881275 100644 --- a/src/plugins/condition/components/Condition.vue +++ b/src/plugins/condition/components/Condition.vue @@ -42,8 +42,28 @@ {{ condition.configuration.name }} - - {{ getSummary }} + + When all else fails + + + +
@@ -159,8 +179,28 @@ Output: {{ condition.configuration.output }}
-
- {{ getSummary }} +
+ When all else fails +
+
+ +
@@ -203,28 +243,6 @@ export default { criterionIndex: 0 }; }, - computed: { - getSummary: function () { - if (!this.condition.configuration.criteria.length) { - return 'When all else fails' - } - let config = this.condition.configuration; - let summary = ''; - if (config.criteria.length === 1 && - config.criteria[0].telemetry && - config.criteria[0].operation) { - summary = this.getRules(config.criteria[0]); - } else { - config.criteria.forEach((criterion, index) => { - if (criterion.telemetry && - criterion.operation) { - summary += this.getRules(criterion, index); - } - }); - } - return summary; - } - }, destroyed() { this.destroy(); }, @@ -232,16 +250,23 @@ export default { this.setOutputSelection(); }, methods: { - getRules(criterion, index) { - let adverb = criterion.input.length === 1 && index === 0 ? 'When ' : ''; - let conjunction = (this.condition.configuration.criteria.length - 1 === index) ? - (this.condition.configuration.trigger === 'all' ? ' and ' : ' or ') : ''; + getRule(criterion, index) { if (criterion.operation) { - if (criterion.input.length || - (criterion.operation === 'isDefined' || - criterion.operation === 'isUndefined')) { - return `${adverb}${conjunction}${criterion.telemetry.name} ${criterion.metadata} value ${this.findDescription(criterion.operation, criterion.input)}`; - } + // this.openmct.objects.get(criterion.telemetry).then((telemetryObject) => { + // this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject); + // this.telemetryMetadataOptions = this.telemetryMetadata.values(); + // let metadataName = ''; + // for (let i = 0; i < this.telemetryMetadataOptions.length; i++) { + // if (criterion.metadata === this.telemetryMetadataOptions[i].key) { + // metadataName = this.telemetryMetadataOptions[i].name; + // } + // } + if (criterion.input.length || + (criterion.operation === 'isDefined' || + criterion.operation === 'isUndefined')) { + return `${criterion.telemetry.name} ${criterion.metadata} ${this.findDescription(criterion.operation, criterion.input)}`; + } + // }); } }, findDescription(operation, values) {