fix sticky telemetry selection issue

This commit is contained in:
Joel McKinnon 2020-03-23 16:16:58 -07:00
parent 44f48a3e2a
commit 168c040f3c
2 changed files with 27 additions and 15 deletions

View File

@ -279,7 +279,7 @@ export default {
this.selectedFieldName = name;
},
getRule(criterion, index) {
return `${this.selectedTelemetryName} ${criterion.telemetry.fieldName} ${this.findDescription(criterion.operation, criterion.input)}`;
return `${this.selectedTelemetryName} ${this.selectedFieldName} ${this.findDescription(criterion.operation, criterion.input)}`;
},
isLastCriterion(index) {
return index === this.condition.configuration.criteria.length - 1;
@ -349,7 +349,7 @@ export default {
this.persist()
},
persist() {
console.log('persist')
console.log('persist called from Condition.vue')
this.$emit('updateCondition', {
condition: this.condition,
index: this.conditionIndex

View File

@ -4,7 +4,8 @@
<span class="c-cdef__label">{{ setRowLabel }}</span>
<span class="c-cdef__controls">
<span class="c-cdef__control">
<select v-model="criterion.telemetry"
<select ref="telemetrySelect"
v-model="criterion.telemetry"
@change="updateMetadataOptions"
>
<option value="">- Select Telemetry -</option>
@ -19,7 +20,8 @@
<span v-if="criterion.telemetry"
class="c-cdef__control"
>
<select v-model="criterion.metadata"
<select ref="metadataSelect"
v-model="criterion.metadata"
@change="updateOperations"
>
<option value="">- Select Field -</option>
@ -34,7 +36,8 @@
<span v-if="criterion.telemetry && criterion.metadata"
class="c-cdef__control"
>
<select v-model="criterion.operation"
<select ref="operationSelect"
v-model="criterion.operation"
@change="updateOperationInputVisibility"
>
<option value="">- Select Comparison -</option>
@ -160,12 +163,14 @@ export default {
});
},
updateMetadataOptions(ev) {
if (ev) {this.clearInputs()}
if (ev) {
this.clearDependentFields(ev.target)
}
if (this.criterion.telemetry) {
this.openmct.objects.get(this.criterion.telemetry).then((telemetryObject) => {
this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject);
this.telemetryMetadataOptions = this.telemetryMetadata.values();
this.updateOperations();
this.updateOperations(ev);
this.updateOperationInputVisibility();
this.$emit('setTelemetryName', telemetryObject.name)
});
@ -174,12 +179,14 @@ export default {
}
},
updateOperations(ev) {
if (ev) {
this.$emit('setFieldName', ev.target.options[ev.target.selectedIndex].text);
this.clearInputs();
this.persist();
if (ev && ev.target === this.$refs.metadataSelect) {
this.clearDependentFields(this.$refs.metadataSelect);
let selectedOptionText = this.$refs.metadataSelect.options[this.$refs.metadataSelect.selectedIndex].text;
this.$emit('setFieldName', selectedOptionText);
}
this.getOperationFormat();
this.persist();
},
updateOperationInputVisibility(ev) {
if (ev) {
@ -194,8 +201,13 @@ export default {
}
}
},
clearInputs() {
clearDependentFields(el) {
if (el === this.$refs.telemetrySelect) {
this.criterion.metadata = '';
this.criterion.operation = '';
} else if (el === this.$refs.metadataSelect) {
this.criterion.operation = '';
}
this.criterion.input = [];
this.inputCount = 0;
},