diff --git a/src/plugins/condition/components/Condition.vue b/src/plugins/condition/components/Condition.vue index 4ab2e7b909..ae041c6ed2 100644 --- a/src/plugins/condition/components/Condition.vue +++ b/src/plugins/condition/components/Condition.vue @@ -2,7 +2,7 @@
@@ -28,7 +28,7 @@ export default { type: Object, required: true }, - isCurrent: { + currentConditionIdentifier: { type: Object, required: true } diff --git a/src/plugins/condition/components/ConditionCollection.vue b/src/plugins/condition/components/ConditionCollection.vue index 9c946b7f18..e8ffa3438d 100644 --- a/src/plugins/condition/components/ConditionCollection.vue +++ b/src/plugins/condition/components/ConditionCollection.vue @@ -35,7 +35,7 @@ >
@@ -80,16 +80,35 @@ export default { }, mounted() { this.telemetryObjs = []; + this.conditionResults = {}; this.instantiate = this.openmct.$injector.get('instantiate'); this.composition = this.openmct.composition.get(this.domainObject); this.composition.on('add', this.addTelemetry); this.composition.load(); this.conditionCollection = this.domainObject.configuration ? this.domainObject.configuration.conditionCollection : []; - if (!this.conditionCollection.length) {this.addCondition(null, true)} + if (!this.conditionCollection.length) { + this.addCondition(null, true); + } else { + this.updateCurrentCondition(this.conditionCollection[0]); + } }, methods: { handleConditionResult(args) { - console.log('ConditionCollection: ', args.result); + let idAsString = this.openmct.objects.makeKeyString(args.id); + this.conditionResults[idAsString] = args.result; + this.updateCurrentConditionId(); + }, + updateCurrentConditionId() { + let currentConditionIdentifier = this.conditionCollection[this.conditionCollection.length-1]; + for (let i=0, ii = this.conditionCollection.length-1; i< ii; i++) { + let conditionIdAsString = this.openmct.objects.makeKeyString(this.conditionCollection[i]); + if (this.conditionResults[conditionIdAsString]) { + //first condition to be true wins + currentConditionIdentifier = this.conditionCollection[i]; + break; + } + } + this.$emit('current-condition-updated', currentConditionIdentifier); }, addTelemetry(telemetryDomainObject) { this.telemetryObjs.push(telemetryDomainObject); @@ -135,12 +154,14 @@ export default { this.conditions[index] = updatedCondition; }, removeCondition(identifier) { - console.log('this.conditions', this.conditions); let index = _.findIndex(this.conditionCollection, (condition) => { - identifier.key === condition.key + let conditionId = this.openmct.objects.makeKeyString(condition); + let id = this.openmct.objects.makeKeyString(identifier); + return conditionId === id; }); - this.conditionCollection.splice(index + 1, 1); + this.conditionCollection.splice(index, 1); this.persist(); + this.updateCurrentConditionId(); }, reorder(reorderPlan) { let oldConditions = this.conditionCollection.slice(); diff --git a/src/plugins/condition/components/ConditionEdit.vue b/src/plugins/condition/components/ConditionEdit.vue index 89d631dce7..034a39a713 100644 --- a/src/plugins/condition/components/ConditionEdit.vue +++ b/src/plugins/condition/components/ConditionEdit.vue @@ -1,7 +1,7 @@