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

Use FormNavigationGuard in intake forms #173

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions frontend/src/components/housing/enquiry/EnquiryIntakeForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import BackButton from '@/components/common/BackButton.vue';
import {
EditableDropdown,
Dropdown,
FormNavigationGuard,
InputMask,
InputText,
RadioList,
Expand Down Expand Up @@ -293,9 +294,6 @@ async function emailConfirmation(activityId: string, enquiryId: string) {
<div v-if="!assignedActivityId">
<div class="mb-2 p-0">
<BackButton
:confirm-leave="editable && !!formUpdated"
confirm-message="Are you sure you want to leave this page?
Any unsaved changes will be lost. Please save as draft first."
:route-name="getBackButtonConfig.routeName"
:text="getBackButtonConfig.text"
/>
Expand All @@ -317,6 +315,8 @@ async function emailConfirmation(activityId: string, enquiryId: string) {
@submit="confirmSubmit"
@change="formUpdated = true"
>
<FormNavigationGuard v-if="editable && !!formUpdated" />

<input
type="hidden"
name="activityId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Calendar,
Checkbox,
Dropdown,
FormNavigationGuard,
InputMask,
InputNumber,
RadioList,
Expand Down Expand Up @@ -307,7 +308,6 @@ async function onSaveDraft(
let response;
try {
if (data.submissionId) {
console.log('save draft');
response = await submissionService.updateDraft(draftData.submissionId, draftData);
} else {
response = await submissionService.createDraft(draftData);
Expand Down Expand Up @@ -485,12 +485,10 @@ onBeforeMount(async () => {
<template>
<div v-if="!assignedActivityId && !assistanceAssignedActivityId">
<BackButton
:confirm-leave="editable && !!formUpdated"
confirm-message="Are you sure you want to leave this page?
Any unsaved changes will be lost. Please save as draft first."
:route-name="getBackButtonConfig.routeName"
:text="getBackButtonConfig.text"
/>

<div class="flex justify-content-center app-primary-color mt-3">
<h3>Project Investigation Form</h3>
</div>
Expand All @@ -506,6 +504,8 @@ onBeforeMount(async () => {
@submit="confirmSubmit"
@change="() => (formUpdated = true)"
>
<FormNavigationGuard v-if="editable && !!formUpdated" />

<SubmissionAssistance
v-if="editable && values?.applicant"
:form-errors="errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ vi.mock('vue-router', () => ({
params: {},
query: {}
}),
onBeforeRouteUpdate: vi.fn()
onBeforeRouteUpdate: vi.fn(),
onBeforeRouteLeave: vi.fn()
}));

const getActivityIds = vi.spyOn(submissionService, 'getActivityIds');
Expand Down
Loading