From c19206be0caaf3d6b99fb8c2d385dbac68e32596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 17 Sep 2025 20:21:50 +0200 Subject: [PATCH] Enhance validation in `PersonEdit`: Introduce `hasValidationError` and `validationError` helpers for form inputs. Improve error feedback for fields such as `firstName`, `lastName`, `gender`, and others. Refactor `postPerson` to handle validation exceptions and map errors to specific fields. Update related methods, styles, and API error type definitions. --- .../Resources/public/lib/api/apiMethods.ts | 4 +- .../vuejs/OnTheFly/components/Create.vue | 11 +- .../vuejs/OnTheFly/components/CreateModal.vue | 17 +- .../Resources/public/types.ts | 6 +- .../Resources/public/vuejs/_api/OnTheFly.ts | 55 ++- .../public/vuejs/_components/AddPersons.vue | 11 +- .../vuejs/_components/OnTheFly/PersonEdit.vue | 434 +++++++++++------- 7 files changed, 355 insertions(+), 183 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts index 36645d51b..79927cc4d 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts @@ -117,9 +117,9 @@ export class ValidationException< * Check that the exception is a ValidationExceptionInterface * @param x */ -export function isValidationException( +export function isValidationException>>( x: unknown, -): x is ValidationExceptionInterface>> { +): x is ValidationExceptionInterface { return ( x instanceof ValidationException || (typeof x === "object" && diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue index ec94b2d88..ca88afb25 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue @@ -56,7 +56,7 @@ import { ONTHEFLY_CREATE_THIRDPARTY, trans, } from "translator"; -import {CreatableEntityType, Person} from "ChillPersonAssets/types"; +import { CreatableEntityType, Person } from "ChillPersonAssets/types"; import { CreateComponentConfig } from "ChillMainAssets/types"; import PersonEdit from "ChillPersonAssets/vuejs/_components/OnTheFly/PersonEdit.vue"; @@ -66,9 +66,8 @@ const props = withDefaults(defineProps(), { query: "", }); -const emit = defineEmits<{ - (e: "onPersonCreated", payload: { person: Person }): void; -}>(); +const emit = + defineEmits<(e: "onPersonCreated", payload: { person: Person }) => void>(); const type = ref(null); @@ -112,9 +111,7 @@ function save(): void { castPerson.value.postPerson(); } -defineExpose({save}); - - +defineExpose({ save });