Addresses review comments

- Use camelCase for events (did not change properties as eslint complains)
- Reduce repeated property access by assigning to a variable
- Use descriptive variable name
This commit is contained in:
Joshi 2020-01-30 11:06:25 -08:00
parent 6f6fb859d6
commit 1ff4d41b7c
4 changed files with 25 additions and 23 deletions

View File

@ -55,7 +55,7 @@ export default {
},
methods: {
handleConditionResult(args) {
this.$emit('condition-result-updated', {
this.$emit('conditionResultUpdated', {
id: this.conditionIdentifier,
result: args.data.result
})

View File

@ -37,15 +37,15 @@
<ConditionEdit :condition-identifier="conditionIdentifier"
:telemetry="telemetryObjs"
:current-condition-identifier="currentConditionIdentifier"
@update-current-condition="updateCurrentCondition"
@remove-condition="removeCondition"
@condition-result-updated="handleConditionResult"
@updateCurrentCondition="updateCurrentCondition"
@removeCondition="removeCondition"
@conditionResultUpdated="handleConditionResult"
/>
</div>
<div v-else>
<Condition :condition-identifier="conditionIdentifier"
@condition-result-updated="handleConditionResult"
:current-condition-identifier="currentConditionIdentifier"
@conditionResultUpdated="handleConditionResult"
/>
</div>
</div>
@ -112,7 +112,7 @@ export default {
break;
}
}
this.$emit('current-condition-updated', currentConditionIdentifier);
this.$emit('currentConditionUpdated', currentConditionIdentifier);
},
addTelemetry(telemetryDomainObject) {
this.telemetryObjs.push(telemetryDomainObject);
@ -128,10 +128,10 @@ export default {
}
},
addCondition(event, isDefault) {
let conditionDO = this.getConditionDomainObject(!!isDefault);
//persist the condition DO so that we can do an openmct.objects.get on it and only persist the identifier in the conditionCollection of conditionSet
this.openmct.objects.mutate(conditionDO, 'created', new Date());
this.conditionCollection.unshift(conditionDO.identifier);
let conditionDomainObject = this.getConditionDomainObject(!!isDefault);
//persist the condition domain object so that we can do an openmct.objects.get on it and only persist the identifier in the conditionCollection of conditionSet
this.openmct.objects.mutate(conditionDomainObject, 'created', new Date());
this.conditionCollection.unshift(conditionDomainObject.identifier);
this.persist();
},
updateCurrentCondition(identifier) {
@ -157,10 +157,10 @@ export default {
},
summary: 'summary description'
};
let conditionDOKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
let newDO = this.instantiate(conditionObj, conditionDOKeyString);
let conditionDomainObjectKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
let newDomainObject = this.instantiate(conditionObj, conditionDomainObjectKeyString);
return newDO.useCapability('adapter');
return newDomainObject.useCapability('adapter');
},
updateCondition(updatedCondition) {
//TODO: this should only happen for reordering

View File

@ -238,19 +238,20 @@ export default {
}
},
handleConditionResult(args) {
this.$emit('condition-result-updated', {
this.$emit('conditionResultUpdated', {
id: this.conditionIdentifier,
result: args.data.result
})
},
removeCondition(ev) {
this.$emit('remove-condition', this.conditionIdentifier);
this.$emit('removeCondition', this.conditionIdentifier);
},
setOutput() {
if (this.condition.definition.output !== 'false' && this.condition.definition.output !== 'true') {
let conditionOutput = this.condition.definition.output;
if (conditionOutput !== 'false' && conditionOutput !== 'true') {
this.selectedOutputKey = this.outputOptions[2].key;
} else {
if (this.condition.definition.output === 'true') {
if (conditionOutput === 'true') {
this.selectedOutputKey = this.outputOptions[1].key;
} else {
this.selectedOutputKey = this.outputOptions[0].key;
@ -307,10 +308,11 @@ export default {
},
updateConditionCriteria() {
if (this.condition.definition.criteria.length) {
this.condition.definition.criteria[0].key = this.selectedTelemetryKey;
this.condition.definition.criteria[0].metaDataKey = this.selectedMetaDataKey;
this.condition.definition.criteria[0].operation = this.selectedOperationKey;
this.condition.definition.criteria[0].input = [this.operationValue];
let criterion = this.condition.definition.criteria[0];
criterion.key = this.selectedTelemetryKey;
criterion.metaDataKey = this.selectedMetaDataKey;
criterion.operation = this.selectedOperationKey;
criterion.input = [this.operationValue];
}
},
persist() {
@ -338,7 +340,7 @@ export default {
this.updateTelemetry();
},
updateCurrentCondition() {
this.$emit('update-current-condition', this.conditionIdentifier);
this.$emit('updateCurrentCondition', this.conditionIdentifier);
}
}
}

View File

@ -5,7 +5,7 @@
<CurrentOutput :condition="currentCondition" />
<TestData :is-editing="isEditing" />
<ConditionCollection :is-editing="isEditing"
@current-condition-updated="updateCurrentCondition"
@currentConditionUpdated="updateCurrentCondition"
/>
</div>
</div>