moved persist calls to events, used emit to save name and fieldname props

This commit is contained in:
Joel McKinnon 2020-03-20 17:37:48 -07:00
parent e08b4ff0ab
commit 44f48a3e2a
2 changed files with 20 additions and 13 deletions

View File

@ -139,6 +139,8 @@
:trigger="condition.configuration.trigger"
:is-default="condition.configuration.criteria.length === 1"
@persist="persist"
@setTelemetryName="setTelemetryName"
@setFieldName="setFieldName"
/>
<div class="c-cdef__criteria__buttons">
<button class="c-click-icon c-cdef__criteria-duplicate-button icon-duplicate"
@ -240,7 +242,9 @@ export default {
trigger: 'all',
selectedOutputSelection: '',
outputOptions: ['false', 'true', 'string'],
criterionIndex: 0
criterionIndex: 0,
selectedTelemetryName: '',
selectedFieldName: ''
};
},
computed: {
@ -268,8 +272,14 @@ export default {
this.setOutputSelection();
},
methods: {
setTelemetryName(name) {
this.selectedTelemetryName = name;
},
setFieldName(name) {
this.selectedFieldName = name;
},
getRule(criterion, index) {
return `${criterion.telemetry.name} ${criterion.telemetry.fieldName} ${this.findDescription(criterion.operation, criterion.input)}`;
return `${this.selectedTelemetryName} ${criterion.telemetry.fieldName} ${this.findDescription(criterion.operation, criterion.input)}`;
},
isLastCriterion(index) {
return index === this.condition.configuration.criteria.length - 1;
@ -337,12 +347,9 @@ export default {
const clonedCriterion = {...this.condition.configuration.criteria[index]};
this.condition.configuration.criteria.splice(index + 1, 0, clonedCriterion);
this.persist()
},
hasTelemetry(identifier) {
// TODO: check parent condition.composition.hasTelemetry
return this.currentCriteria && identifier;
},
},
persist() {
console.log('persist')
this.$emit('updateCondition', {
condition: this.condition,
index: this.conditionIndex

View File

@ -163,11 +163,11 @@ export default {
if (ev) {this.clearInputs()}
if (this.criterion.telemetry) {
this.openmct.objects.get(this.criterion.telemetry).then((telemetryObject) => {
this.criterion.telemetry.name = telemetryObject.name;
this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject);
this.telemetryMetadataOptions = this.telemetryMetadata.values();
this.updateOperations();
this.updateOperationInputVisibility();
this.$emit('setTelemetryName', telemetryObject.name)
});
} else {
this.criterion.metadata = '';
@ -175,16 +175,17 @@ export default {
},
updateOperations(ev) {
if (ev) {
this.criterion.telemetry.fieldName = ev.target.options[ev.target.selectedIndex].text;
this.clearInputs()
this.$emit('setFieldName', ev.target.options[ev.target.selectedIndex].text);
this.clearInputs();
this.persist();
}
this.getOperationFormat();
this.persist();
this.getOperationFormat();
},
updateOperationInputVisibility(ev) {
if (ev) {
this.criterion.input = this.enumerations.length ? [this.enumerations[0].value.toString()] : [];
this.inputCount = 0;
this.persist();
}
for (let i = 0; i < this.filteredOps.length; i++) {
if (this.criterion.operation === this.filteredOps[i].name) {
@ -192,7 +193,6 @@ export default {
if (!this.inputCount) {this.criterion.input = []}
}
}
this.persist();
},
clearInputs() {
this.criterion.operation = '';