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: { methods: {
handleConditionResult(args) { handleConditionResult(args) {
this.$emit('condition-result-updated', { this.$emit('conditionResultUpdated', {
id: this.conditionIdentifier, id: this.conditionIdentifier,
result: args.data.result result: args.data.result
}) })

View File

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

View File

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

View File

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