From 7136c682f2cc4f766a6fb7cefd76b77cd02ecf57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 7 Nov 2025 17:21:03 +0100 Subject: [PATCH] Refactor `Person.vue` and `ThirdParty.vue` to enhance data loading and improve conditional rendering. - Added `loadData` method in `Person.vue` to handle person data fetching based on props. - Improved `ThirdParty.vue` by refining conditional checks and updating prop types for better maintainability. --- .../vuejs/_components/OnTheFly/Person.vue | 18 ++++++++ .../vuejs/_components/OnTheFly/ThirdParty.vue | 41 +++++++++++-------- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index 451fe9179..d2f9d33a5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -48,4 +48,22 @@ const props = withDefaults(defineProps(), {query: ""}); const person = ref(null); +function loadData(): void { + if (props.id === undefined || props.id === null) { + return; + } + const idNum = props.id; + if (!Number.isFinite(idNum)) { + return; + } + getPerson(idNum as number).then((p) => { + person.value = p; + }); +} + +onMounted(() => { + if (props.action !== "create") { + loadData(); + } +}); diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 897b2617b..dd67587e5 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -1,5 +1,5 @@ -