From ed71cffd6a3c1b3b1c1af7e65a964bb8eb13acd4 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 11 Mar 2025 07:19:52 +0100 Subject: [PATCH] Change behavior of information exchange between backend and frontend --- ...ompanyingPeriodWorkDuplicateController.php | 9 +- .../AccompanyingPeriodWorkSelector.js | 4 +- .../Resources/public/types.ts | 88 ++++++++++++++++++- .../AccompanyingPeriodWorkItem.vue | 4 +- .../AccompanyingPeriodWorkList.vue | 15 ++-- .../AccompanyingPeriodWorkSelectorModal.vue | 51 +++++++++-- .../assign_acpw_duplicate.html.twig | 2 +- 7 files changed, 147 insertions(+), 26 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php index a1dd91121..8d373626a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php @@ -33,8 +33,7 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController public function assignDuplicate(AccompanyingPeriodWork $acpw, Request $request) { $accompanyingPeriod = $acpw->getAccompanyingPeriod(); - - $acpwArray = $this->accompanyingPeriodWorkRepository->findByAccompanyingPeriod($accompanyingPeriod); +/* $acpwArray = $this->accompanyingPeriodWorkRepository->findByAccompanyingPeriod($accompanyingPeriod); $acpwArray = array_map(function ($acpw) { return [ @@ -43,7 +42,7 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController 'startDate' => $acpw->getStartDate(), 'endDate' => $acpw->getEndDate(), ]; - }, $acpwArray); + }, $acpwArray);*/ $this->denyAccessUnlessGranted( 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', @@ -76,8 +75,8 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController } return $this->render('@ChillPerson/AccompanyingPeriodWorkDuplicate/assign_acpw_duplicate.html.twig', [ - 'accompanyingCourse' => $acpw->getAccompanyingPeriod(), - 'acpwArray' => $acpwArray, + 'accompanyingCourse' => $accompanyingPeriod, +// 'acpwArray' => $acpwArray, 'acpw' => $acpw, 'form' => $form->createView(), ]); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/mod/DuplicateSelector/AccompanyingPeriodWorkSelector.js b/src/Bundle/ChillPersonBundle/Resources/public/mod/DuplicateSelector/AccompanyingPeriodWorkSelector.js index 2231aeab6..0a0dc349b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/mod/DuplicateSelector/AccompanyingPeriodWorkSelector.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/mod/DuplicateSelector/AccompanyingPeriodWorkSelector.js @@ -4,7 +4,7 @@ import AccompanyingPeriodWorkSelectorModal from "../../vuejs/_components/Accompa document.addEventListener("DOMContentLoaded", () => { const el = document.getElementById('linked-acpw-selector'); if (el) { - const acpwList = JSON.parse(el.dataset.acpwArray); - createApp(AccompanyingPeriodWorkSelectorModal, { acpwList }).mount(el); + const accompanyingPeriodId = el.dataset.accompanyingPeriod; + createApp(AccompanyingPeriodWorkSelectorModal, { accompanyingPeriodId }).mount(el); } }); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/types.ts b/src/Bundle/ChillPersonBundle/Resources/public/types.ts index c93440d75..87c42a90c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/types.ts +++ b/src/Bundle/ChillPersonBundle/Resources/public/types.ts @@ -1,13 +1,16 @@ import { Address, + Scope, Center, Civility, DateTime, User, WorkflowAvailable, -} from "../../../ChillMainBundle/Resources/public/types"; -import { StoredObject } from "../../../ChillDocStoreBundle/Resources/public/types"; + Job, +} from "ChillMainAssets/types"; +import { StoredObject } from "ChillDocStoreAssets/types"; import {Thirdparty} from "../../../ChillThirdPartyBundle/Resources/public/types"; +import {Calendar} from "../../../ChillCalendarBundle/Resources/public/types"; export interface Person { id: number; @@ -30,6 +33,37 @@ export interface Person { current_residential_addresses: Address[]; } +export interface AccompanyingPeriod { + id: number; + addressLocation?: Address | null; + administrativeLocation?: Location | null; + calendars: Calendar[]; + closingDate?: Date | null; + closingMotive?: ClosingMotive | null; + comments: Comment[]; + confidential: boolean; + createdAt?: Date | null; + createdBy?: User | null; + emergency: boolean; + intensity?: 'occasional' | 'regular'; + job?: Job | null; + locationHistories: AccompanyingPeriodLocationHistory[]; + openingDate?: Date | null; + origin?: Origin | null; + participations: AccompanyingPeriodParticipation[]; + personLocation?: Person | null; + pinnedComment?: Comment | null; + preventUserIsChangedNotification: boolean; + remark: string; + requestorAnonymous: boolean; + requestorPerson?: Person | null; + requestorThirdParty?: Thirdparty | null; + resources: AccompanyingPeriodResource[]; + scopes: Scope[]; + socialIssues: SocialIssue[]; + step?: 'CLOSED' | 'CONFIRMED' | 'CONFIRMED_INACTIVE_SHORT' | 'CONFIRMED_INACTIVE_LONG' | 'DRAFT'; +} + export interface AccompanyingPeriodWorkEvaluationDocument { id: number; type: "accompanying_period_work_evaluation_document"; @@ -73,7 +107,9 @@ interface SocialAction { children: SocialAction[]; issue?: SocialIssue | null; ordering: number; - title: Record; + title: { + fr: string; + }; defaultNotificationDelay?: string | null; desactivationDate?: string | null; evaluations: Evaluation[]; @@ -81,11 +117,55 @@ interface SocialAction { results: Result[]; } +export interface AccompanyingPeriodResource { + id: number; + accompanyingPeriod: AccompanyingPeriod; + comment?: string | null; + person?: Person | null; + thirdParty?: Thirdparty | null; +} + +export interface Origin { + id: number; + label: { + fr: string; + }; + noActiveAfter: DateTime; +} + +export interface ClosingMotive { + id: number; + active: boolean; + name: { + fr: string; + }; + ordering: number; + isCanceledAccompanyingPeriod: boolean; + parent?: ClosingMotive | null; + children: ClosingMotive[]; +} + +export interface AccompanyingPeriodParticipation { + id: number; + startDate: DateTime; + endDate?: DateTime | null; + accompanyingPeriod: AccompanyingPeriod; + person: Person; +} + +export interface AccompanyingPeriodLocationHistory { + id: number; + startDate: DateTime; + endDate?: DateTime | null; + addressLocation?: Address | null; + period: AccompanyingPeriod; + personLocation?: Person | null; +} + type SocialIssue = any; type Goal = any; type Result = any; type Evaluation = any; -type AccompanyingPeriod = any; type AccompanyingPeriodWorkEvaluation = any; type AccompanyingPeriodWorkGoal = any; type PrivateCommentEmbeddable = any; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkItem.vue index e8d7752bf..c681c46c7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkItem.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkItem.vue @@ -7,7 +7,7 @@ - {{ acpw.socialAction }} + {{ acpw?.socialAction?.title.fr }} @@ -43,7 +43,7 @@ const props = defineProps<{ acpw: AccompanyingPeriodWork }>(); const formatDate = (dateObject) => { if(dateObject) { - const parsedDate = ISOToDate(dateObject.date); + const parsedDate = ISOToDate(dateObject.datetime); return new Intl.DateTimeFormat('default', { dateStyle: 'short' }).format(parsedDate); } }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkList.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkList.vue index 3932034b1..6f545e1e8 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkList.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkList.vue @@ -1,6 +1,6 @@