Commit 03092f3d authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Address minor review comments

parent bc8266dc
...@@ -38,7 +38,7 @@ export const initializeFormData = ({ emptyFieldState, initialFields, errors }) = ...@@ -38,7 +38,7 @@ export const initializeFormData = ({ emptyFieldState, initialFields, errors }) =
: { : {
...emptyFieldState, ...emptyFieldState,
endEventIdentifier: endEventIdentifier:
initialFields && !initialFields?.startEventIdentifier initialFields && !initialFields.startEventIdentifier
? [s__('CustomCycleAnalytics|Please select a start event first')] ? [s__('CustomCycleAnalytics|Please select a start event first')]
: null, : null,
}; };
...@@ -97,10 +97,15 @@ export default { ...@@ -97,10 +97,15 @@ export default {
}, },
data() { data() {
const { initialFields = {}, errors = null } = this; const { initialFields = {}, errors = null } = this;
const formData = initializeFormData({ emptyFieldState: defaultFields, initialFields, errors }); const { fields, fieldErrors } = initializeFormData({
emptyFieldState: defaultFields,
initialFields,
errors,
});
return { return {
labelEvents: getLabelEventsIdentifiers(this.events), labelEvents: getLabelEventsIdentifiers(this.events),
...formData, fields,
fieldErrors,
}; };
}, },
computed: { computed: {
...@@ -130,7 +135,7 @@ export default { ...@@ -130,7 +135,7 @@ export default {
hasErrors() { hasErrors() {
return ( return (
this.eventMismatchError || this.eventMismatchError ||
Object.values(this.fieldErrors).some(errArray => errArray && errArray.length) Object.values(this.fieldErrors).some(errArray => errArray?.length)
); );
}, },
isComplete() { isComplete() {
...@@ -281,7 +286,6 @@ export default { ...@@ -281,7 +286,6 @@ export default {
:label="s__('CustomCycleAnalytics|Name')" :label="s__('CustomCycleAnalytics|Name')"
:state="!hasFieldErrors('name')" :state="!hasFieldErrors('name')"
:invalid-feedback="fieldErrorMessage('name')" :invalid-feedback="fieldErrorMessage('name')"
@change.native="onUpdateNameField"
> >
<gl-form-input <gl-form-input
v-model="fields.name" v-model="fields.name"
...@@ -290,6 +294,7 @@ export default { ...@@ -290,6 +294,7 @@ export default {
name="custom-stage-name" name="custom-stage-name"
:placeholder="s__('CustomCycleAnalytics|Enter a name for the stage')" :placeholder="s__('CustomCycleAnalytics|Enter a name for the stage')"
required required
@change.native="onUpdateNameField"
/> />
</gl-form-group> </gl-form-group>
<div class="d-flex" :class="{ 'justify-content-between': startEventRequiresLabel }"> <div class="d-flex" :class="{ 'justify-content-between': startEventRequiresLabel }">
...@@ -333,7 +338,6 @@ export default { ...@@ -333,7 +338,6 @@ export default {
:label="s__('CustomCycleAnalytics|Stop event')" :label="s__('CustomCycleAnalytics|Stop event')"
:state="!hasFieldErrors('endEventIdentifier')" :state="!hasFieldErrors('endEventIdentifier')"
:invalid-feedback="fieldErrorMessage('endEventIdentifier')" :invalid-feedback="fieldErrorMessage('endEventIdentifier')"
@change.native="onUpdateEndEventField"
> >
<gl-form-select <gl-form-select
v-model="fields.endEventIdentifier" v-model="fields.endEventIdentifier"
...@@ -341,6 +345,7 @@ export default { ...@@ -341,6 +345,7 @@ export default {
:options="endEventOptions" :options="endEventOptions"
:required="true" :required="true"
:disabled="!hasStartEvent" :disabled="!hasStartEvent"
@change.native="onUpdateEndEventField"
/> />
</gl-form-group> </gl-form-group>
</div> </div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment