From bed14c26e50cc667f97a1808e34bd6083698ed1d Mon Sep 17 00:00:00 2001 From: Blesilda Ramirez Date: Sat, 25 Jan 2025 00:22:38 -0500 Subject: [PATCH 1/4] pkp/pkp-lib#10820 Add FormErrorSummary component --- src/components/Form/Form.stories.js | 40 ++++++++++++++++++++++++ src/components/Form/FormErrorSummary.vue | 32 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/components/Form/FormErrorSummary.vue diff --git a/src/components/Form/Form.stories.js b/src/components/Form/Form.stories.js index 3acca87b5..9a91c90e0 100644 --- a/src/components/Form/Form.stories.js +++ b/src/components/Form/Form.stories.js @@ -1,4 +1,5 @@ import Form from './Form.vue'; +import FormErrorSummary from './FormErrorSummary.vue'; import {useContainerStateManager} from '@/composables/useContainerStateManager'; import FormBase from './mocks/form-base'; import FormMultilingual from './mocks/form-multilingual'; @@ -126,3 +127,42 @@ export const WithErrors = { args: {}, }; + +export const WithErrorSummary = { + render: (args) => ({ + components: {PkpForm: Form, FormErrorSummary}, + setup() { + const {get, set, components} = useContainerStateManager(); + const errors = { + email: ['Please provide a valid email address'], + affiliation: { + en: ['You must enter your affiliation in English.'], + fr_CA: ['You must enter your affiliation in French.'], + ar: ['You must enter your affiliation in Arabic.'], + }, + 'user-locales': ['You must select at least two options.'], + bio: { + en: ['Please provide a bio statement to accompany your publication.'], + }, + country: ['Please select your country.'], + 'mailing-address': [ + 'You must enter a mailing address where you can receive post.', + ], + }; + set('errorSummary', { + ...FormUser, + ...args, + errors, + }); + return {args, errors, get, set, components}; + }, + template: ` + + + `, + }), + + args: { + showErrorFooter: false, + }, +}; diff --git a/src/components/Form/FormErrorSummary.vue b/src/components/Form/FormErrorSummary.vue new file mode 100644 index 000000000..3fa04d4bd --- /dev/null +++ b/src/components/Form/FormErrorSummary.vue @@ -0,0 +1,32 @@ + + + From 7a898b825bcd2ad042c47dabf7d769208f08ac70 Mon Sep 17 00:00:00 2001 From: Blesilda Ramirez Date: Sat, 25 Jan 2025 00:25:02 -0500 Subject: [PATCH 2/4] pkp/pkp-lib#10820 Add showErrorFooter prop in Form and FormPage components --- src/components/Form/Form.vue | 8 ++++++++ src/components/Form/FormPage.vue | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/Form/Form.vue b/src/components/Form/Form.vue index cd3555845..2a5512260 100644 --- a/src/components/Form/Form.vue +++ b/src/components/Form/Form.vue @@ -61,6 +61,7 @@ :visible-locales="visibleLocales" :available-locales="availableLocales" :is-saving="isSaving" + :show-error-footer="showErrorFooter" @change="fieldChanged" @page-submitted="nextPage" @previous-page="setCurrentPage(false)" @@ -135,6 +136,13 @@ export default { * Async function, receiving data from form and returning {validationError, data} from useFetch */ customSubmit: Function, + /** If the error summary is shown in the form's footer. */ + showErrorFooter: { + type: Boolean, + default() { + return true; + }, + }, }, emits: [ /** When the form props need to be updated. The payload is an object with any keys that need to be modified. */ diff --git a/src/components/Form/FormPage.vue b/src/components/Form/FormPage.vue index 72af383a4..e20b01527 100644 --- a/src/components/Form/FormPage.vue +++ b/src/components/Form/FormPage.vue @@ -20,7 +20,7 @@ aria-live="polite" > Date: Sat, 25 Jan 2025 00:27:19 -0500 Subject: [PATCH 3/4] pkp/pkp-lib#10820 Use FormErrorSummary in UserInvitationDetailsFormStep component --- src/pages/userInvitation/UserInvitationDetailsFormStep.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages/userInvitation/UserInvitationDetailsFormStep.vue b/src/pages/userInvitation/UserInvitationDetailsFormStep.vue index ce0e97851..7ac9b8a28 100644 --- a/src/pages/userInvitation/UserInvitationDetailsFormStep.vue +++ b/src/pages/userInvitation/UserInvitationDetailsFormStep.vue @@ -1,8 +1,12 @@