Updates to operation show up in conditionclass

This commit is contained in:
Joshi 2020-01-22 13:01:23 -08:00
parent cdb7066bed
commit ab6e87ae6b
2 changed files with 16 additions and 15 deletions

View File

@ -1,20 +1,20 @@
<template> <template>
<div id="conditionArea" <div id="conditionArea"
v-if="condition" v-if="condition && condition.definition"
class="c-cs-ui__conditions" class="c-cs-ui__conditions"
:class="['widget-condition', { 'widget-condition--current': condition.isCurrent }]" :class="['widget-condition', { 'widget-condition--current': condition.isCurrent }]"
> >
<div class="title-bar"> <div class="title-bar">
<span class="condition-name"> <span class="condition-name">
{{ condition.name }} {{ condition.definition.name }}
</span> </span>
<span class="condition-output"> <span class="condition-output">
Output: {{ condition.output }} Output: {{ condition.definition.output }}
</span> </span>
</div> </div>
<div class="condition-config"> <div class="condition-config">
<span class="condition-description"> <span class="condition-description">
{{ condition.description }} {{ condition.definition.description }}
</span> </span>
</div> </div>
</div> </div>
@ -36,9 +36,7 @@ export default {
}; };
}, },
mounted() { mounted() {
this.condition = {};
this.openmct.objects.get(this.conditionIdentifier).then((obj => { this.openmct.objects.get(this.conditionIdentifier).then((obj => {
console.log('ConditionEdit obj', obj);
this.condition = obj; this.condition = obj;
})); }));
}, },

View File

@ -107,7 +107,9 @@
</select> </select>
</span> </span>
<span class="controls"> <span class="controls">
<select @change="getOperationKey"> <select v-model="selectedOperationKey"
@change="operationKeyChange"
>
<option value="">- Select Comparison -</option> <option value="">- Select Comparison -</option>
<option v-for="option in operations" <option v-for="option in operations"
:key="option.name" :key="option.name"
@ -176,6 +178,7 @@ export default {
}; };
}, },
destroyed() { destroyed() {
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') { if (this.conditionClass && typeof this.conditionClass.destroy === 'function') {
this.conditionClass.destroy(); this.conditionClass.destroy();
} }
@ -183,10 +186,10 @@ export default {
mounted() { mounted() {
this.openmct.objects.get(this.conditionIdentifier).then((obj => { this.openmct.objects.get(this.conditionIdentifier).then((obj => {
this.condition = obj; this.condition = obj;
this.conditionClass = new ConditionClass(this.condition, this.openmct);
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this))
this.setOutput(); this.setOutput();
this.updateTelemetry(); this.updateTelemetry();
this.conditionClass = new ConditionClass(this.condition, this.openmct);
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
})); }));
}, },
updated() { updated() {
@ -235,7 +238,7 @@ export default {
hasTelemetry() { hasTelemetry() {
return this.condition.definition.criteria.length && this.condition.definition.criteria[0].key; return this.condition.definition.criteria.length && this.condition.definition.criteria[0].key;
}, },
persist(index) { //this should only persist the condition domain object persist() {
this.openmct.objects.mutate(this.condition, 'definition', this.condition.definition); this.openmct.objects.mutate(this.condition, 'definition', this.condition.definition);
}, },
checkInputValue() { checkInputValue() {
@ -243,19 +246,19 @@ export default {
this.condition.definition.output = ''; this.condition.definition.output = '';
} }
}, },
getOperationKey(ev) { operationKeyChange(ev) {
if (ev.target.value !== 'isUndefined' && ev.target.value !== 'isDefined') { if (ev.target.value !== 'isUndefined' && ev.target.value !== 'isDefined') {
this.comparisonValueField = true; this.comparisonValueField = true;
} else { } else {
this.comparisonValueField = false; this.comparisonValueField = false;
} }
this.selectedOperationKey = ev.target.value; this.condition.definition.criteria[0].operation = this.selectedOperationKey;
this.condition.definition.operator = this.selectedOperationKey;
this.persist(); this.persist();
//find the criterion being updated and set the operator property //find the criterion being updated and set the operation property
}, },
getOperationValue(ev) { getOperationValue(ev) {
this.selectedOperationKey = ev.target.value; this.condition.definition.criteria[0].input = [ev.target.value];
this.persist();
//find the criterion being updated and set the input property //find the criterion being updated and set the input property
} }
} }