From cac260c130cced8f1e2dbfdebfec0e42e2c4e8e8 Mon Sep 17 00:00:00 2001 From: Corinna Hillebrand Date: Wed, 28 Aug 2024 19:18:53 +0200 Subject: [PATCH] Create combined ErrorSummary component - combines error items for payment and address data https://phabricator.wikimedia.org/T368525 --- .../SinglePageErrorSummary.vue | 216 ++++++++++++++++++ .../PersonalDataSection.vue | 11 +- .../PersonalDataSectionDonationReceipt.vue | 5 +- .../SinglePageErrorSummary.vue | 216 ++++++++++++++++++ .../usePersonalDataSectionEventHandlers.ts | 17 +- 5 files changed, 454 insertions(+), 11 deletions(-) create mode 100644 src/components/pages/donation_form/StreetAutocomplete/SinglePageErrorSummary.vue create mode 100644 src/components/pages/donation_form/singlePageFromSections/SinglePageErrorSummary.vue diff --git a/src/components/pages/donation_form/StreetAutocomplete/SinglePageErrorSummary.vue b/src/components/pages/donation_form/StreetAutocomplete/SinglePageErrorSummary.vue new file mode 100644 index 000000000..5a6f36057 --- /dev/null +++ b/src/components/pages/donation_form/StreetAutocomplete/SinglePageErrorSummary.vue @@ -0,0 +1,216 @@ + + + diff --git a/src/components/pages/donation_form/singlePageFromSections/PersonalDataSection.vue b/src/components/pages/donation_form/singlePageFromSections/PersonalDataSection.vue index df6444e9d..0c6cd838d 100644 --- a/src/components/pages/donation_form/singlePageFromSections/PersonalDataSection.vue +++ b/src/components/pages/donation_form/singlePageFromSections/PersonalDataSection.vue @@ -43,11 +43,11 @@ @@ -92,9 +92,10 @@ import ScrollTarget from '@src/components/shared/ScrollTarget.vue'; import PaymentBankData from '@src/components/shared/PaymentBankData.vue'; import AddressTypeBasic from '@src/components/pages/donation_form/AddressTypeBasic.vue'; import AddressForms from '@src/components/pages/donation_form/AddressForms.vue'; -import AddressFormErrorSummaries from '@src/components/pages/donation_form/AddressFormErrorSummaries.vue'; -import StreetAutocompleteAddressFormErrorSummaries - from '@src/components/pages/donation_form/StreetAutocomplete/AddressFormErrorSummaries.vue'; +import SinglePageErrorSummary + from '@src/components/pages/donation_form/singlePageFromSections/SinglePageErrorSummary.vue'; +import StreetAutocompleteSinglePageErrorSummaries + from '@src/components/pages/donation_form/StreetAutocomplete/SinglePageErrorSummary.vue'; import PaymentTextFormButton from '@src/components/shared/form_elements/PaymentTextFormButton.vue'; import FormButton from '@src/components/shared/form_elements/FormButton.vue'; import DonationSummary from '@src/components/pages/donation_form/DonationSummary.vue'; diff --git a/src/components/pages/donation_form/singlePageFromSections/PersonalDataSectionDonationReceipt.vue b/src/components/pages/donation_form/singlePageFromSections/PersonalDataSectionDonationReceipt.vue index 264a6b0cd..d5e0b7241 100644 --- a/src/components/pages/donation_form/singlePageFromSections/PersonalDataSectionDonationReceipt.vue +++ b/src/components/pages/donation_form/singlePageFromSections/PersonalDataSectionDonationReceipt.vue @@ -73,7 +73,7 @@ - -import AddressFormErrorSummaries - from '@src/components/pages/donation_form/DonationReceipt/AddressFormErrorSummaries.vue'; import ScrollTarget from '@src/components/shared/ScrollTarget.vue'; import EmailField from '@src/components/shared/form_fields/EmailField.vue'; import MailingListField from '@src/components/shared/form_fields/MailingListField.vue'; @@ -156,6 +154,7 @@ import { import { Validity } from '@src/view_models/Validity'; import { trackDynamicForm } from '@src/util/tracking'; import { adjustSalutationLocaleIfNeeded } from '@src/components/shared/SalutationLocaleAdjuster'; +import SinglePageErrorSummary from '@src/components/pages/donation_form/singlePageFromSections/SinglePageErrorSummary.vue'; interface Props { assetsPath: string; diff --git a/src/components/pages/donation_form/singlePageFromSections/SinglePageErrorSummary.vue b/src/components/pages/donation_form/singlePageFromSections/SinglePageErrorSummary.vue new file mode 100644 index 000000000..fa8f4e06d --- /dev/null +++ b/src/components/pages/donation_form/singlePageFromSections/SinglePageErrorSummary.vue @@ -0,0 +1,216 @@ + + + diff --git a/src/components/pages/donation_form/usePersonalDataSectionEventHandlers.ts b/src/components/pages/donation_form/usePersonalDataSectionEventHandlers.ts index 75817e11c..ecccb7cb1 100644 --- a/src/components/pages/donation_form/usePersonalDataSectionEventHandlers.ts +++ b/src/components/pages/donation_form/usePersonalDataSectionEventHandlers.ts @@ -36,13 +36,13 @@ export function usePersonalDataSectionEventHandlers( validateEmailUrl: string, ): ReturnType { const submitValuesForm = ref(); + const paymentDataIsValid = ref( true ); const bankDataIsValid = ref( true ); const addressDataIsValid = ref( true ); - const showErrorSummary = computed( () => !bankDataIsValid.value || !addressDataIsValid.value ); + const showErrorSummary = computed( () => !bankDataIsValid.value || !addressDataIsValid.value || !paymentDataIsValid.value ); const submit = async (): Promise => { const validationCalls: Promise[] = [ - //TODO add more payment validation calls here - // store.dispatch( action( 'payment', 'markEmptyValuesAsInvalid' ) ), + store.dispatch( action( 'payment', 'markEmptyValuesAsInvalid' ) ), store.dispatch( action( 'address', 'validateAddressType' ), { type: store.state.address.addressType, disallowed: [ AddressTypeModel.UNSET ], @@ -59,6 +59,11 @@ export function usePersonalDataSectionEventHandlers( // We need to wait for the asynchronous bank data validation, that might still be going on await waitForServerValidationToFinish( store ); + if ( !store.getters[ 'payment/paymentDataIsValid' ] ) { + paymentDataIsValid.value = false; + return; + } + if ( !store.getters[ 'address/requiredFieldsAreValid' ] ) { addressDataIsValid.value = false; return; @@ -75,6 +80,12 @@ export function usePersonalDataSectionEventHandlers( submitValuesForm.value.submit(); }; + store.watch( ( state, getters ) => getters[ 'payment/requiredFieldsAreValid' ], ( isValid: boolean ) => { + if ( !paymentDataIsValid.value && isValid ) { + paymentDataIsValid.value = true; + } + } ); + store.watch( ( state, getters ) => getters[ 'address/requiredFieldsAreValid' ], ( isValid: boolean ) => { if ( !addressDataIsValid.value && isValid ) { addressDataIsValid.value = true;