Display the current output based on the first condition that has evaluated to true.

Fix remove condition
This commit is contained in:
Joshi 2020-01-22 21:35:22 -08:00
parent cfd9730055
commit 0bf3597147
4 changed files with 42 additions and 18 deletions

View File

@ -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);
}
},
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();

View File

@ -256,6 +256,8 @@ export default {
checkInputValue() {
if (this.selectedOutputKey === this.outputOptions[2].key) {
this.condition.definition.output = '';
} else {
this.condition.definition.output = this.selectedOutputKey;
}
},
operationKeyChange(ev) {

View File

@ -5,7 +5,7 @@
<CurrentOutput :condition="currentCondition" />
<TestData :is-editing="isEditing" />
<ConditionCollection :is-editing="isEditing"
@update-current-condition="updateCurrentcondition"
@current-condition-updated="updateCurrentCondition"
/>
</div>
</div>
@ -17,7 +17,6 @@ import CurrentOutput from './CurrentOutput.vue';
import TestData from './TestData.vue';
import ConditionCollection from './ConditionCollection.vue';
export default {
inject: ["openmct", "domainObject"],
components: {
@ -35,20 +34,19 @@ export default {
},
mounted() {
let conditionCollection = this.domainObject.configuration.conditionCollection;
this.currentConditionIdentifier = conditionCollection.length ? this.domainObject.configuration.conditionCollection[0] : null;
if (this.currentConditionIdentifier) {
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
this.currentCondition = obj;
});
}
this.currentConditionIdentifier = conditionCollection.length ? this.updateCurrentCondition(conditionCollection[0]) : null;
},
methods: {
updateCurrentcondition(identifier) {
this.currentConditionIdentifier = identifier;
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
this.currentCondition = obj;
});
setCurrentCondition() {
if (this.currentConditionIdentifier) {
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
this.currentCondition = obj;
});
}
},
updateCurrentCondition(conditionIdentifier) {
this.currentConditionIdentifier = conditionIdentifier;
this.setCurrentCondition();
}
}
};

View File

@ -36,6 +36,9 @@ export default {
}
},
mounted() {
},
updated() {
},
methods: {