Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FSADT1-1050] Adjust "Submit application" button #679

Merged
merged 2 commits into from
Dec 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 33 additions & 17 deletions frontend/src/pages/FormBCSCPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const addContact = (autoFocus = true) => {
);
if (autoFocus) {
const focusIndex = newLength - 1;
setFocusedComponent(`role_${focusIndex}`);
setFocusedComponent(`firstName_${focusIndex}`);
}
return newLength;
};
Expand Down Expand Up @@ -172,7 +172,7 @@ const updateContact = (value: Contact | undefined, index: number) => {
revalidate.value = !revalidate.value;
};

//Validation
// Validation
const validation = reactive<Record<string, boolean>>({
0: false,
});
Expand All @@ -195,7 +195,11 @@ const emit = defineEmits<{
(e: "valid", value: boolean): void;
}>();

watch([validation], () => emit("valid", checkValid()));
watch([validation], () => {
const valid = checkValid();
emit("valid", valid);
submitBtnDisabled.value = !valid;
});
emit("valid", false);

const bus = useEventBus<ModalNotification>("modal-notification");
Expand Down Expand Up @@ -243,7 +247,7 @@ const progressData = reactive([
},
]);

let submitBtnDisabled = ref(false);
const submitBtnDisabled = ref(true);

const errorBus = useEventBus<ValidationMessageType[]>(
"submission-error-notification"
Expand Down Expand Up @@ -299,9 +303,11 @@ const submit = () => {
notificationBus.emit(undefined);

if (checkStepValidity(currentTab.value)) {
submitBtnDisabled.value = true;
submitBtnDisabled.value = false;
console.log(toRef(formData).value);
fecthSubmit();
} else {
submitBtnDisabled.value = true;
}
};

Expand Down Expand Up @@ -416,8 +422,8 @@ watch([error], () => {
submissionValidation(`location.contacts[0].phoneNumber`)
]"
:error-message="errorMessage"
@empty="validation.phoneNumber = !$event"
@error="validation.phoneNumber = !$event"
@empty="validation[0] = !$event"
@error="validation[0] = !$event"
/>
</div>

Expand Down Expand Up @@ -468,16 +474,26 @@ watch([error], () => {

<hr class="divider" />

<cds-button
data-test="wizard-submit-button"
kind="primary"
size="lg"
@click.prevent="submit"
:disabled="submitBtnDisabled"
>
<span>Submit application</span>
<Check16 slot="icon" />
</cds-button>
<div class="form-footer-group-next">
<span class="body-compact-01" v-if="submitBtnDisabled">
All fields must be filled in correctly to enable the “Submit application” button below.
</span>
<cds-tooltip>
<cds-button
data-test="wizard-submit-button"
kind="primary"
size="lg"
v-on:click="submit"
:disabled="submitBtnDisabled"
>
<span>Submit application</span>
<Check16 slot="icon" />
</cds-button>
<cds-tooltip-content v-show="submitBtnDisabled">
All fields must be filled in correctly.
</cds-tooltip-content>
</cds-tooltip>
</div>

<cds-modal
id="address-change-bc-modal"
Expand Down