From 14dba221818e9d23d7386b2fb37291e771399241 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 13 Aug 2025 11:52:19 +0200 Subject: [PATCH] wip: enable moving documents to evaluations - Add `AccompanyingPeriodWorkEvaluationDocumentMoveController` for move functionality - Update `DocumentsList.vue` to emit move event - Adjust `FormEvaluation.vue` to handle move action --- ...odWorkEvaluationDocumentMoveController.php | 60 +++++++++++++++++++ .../components/DocumentsList.vue | 5 +- .../components/FormEvaluation.vue | 4 +- 3 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationDocumentMoveController.php diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationDocumentMoveController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationDocumentMoveController.php new file mode 100644 index 000000000..124ad0463 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationDocumentMoveController.php @@ -0,0 +1,60 @@ +getAccompanyingPeriodWork(); + + if (!$this->security->isGranted(AccompanyingPeriodWorkVoter::UPDATE, $work)) { + throw new AccessDeniedHttpException('not allowed to edit this accompanying period work'); + } + + // Simply set the new evaluation - Doctrine will handle the collection updates + $document->setAccompanyingPeriodWorkEvaluation($evaluation); + + $this->entityManager->persist($document); + $this->entityManager->flush(); + + return new JsonResponse( + $this->serializer->serialize($document, 'json', [AbstractNormalizer::GROUPS => ['read']]), + json: true + ); + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/DocumentsList.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/DocumentsList.vue index abe797824..ad65d2fec 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/DocumentsList.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/DocumentsList.vue @@ -293,7 +293,10 @@ watch(selectedEvaluation, (val) => { document: selectedDocumentToDuplicate.value, }); } else { - console.log('this is the document to move', selectedDocumentToMove.value); + emit("moveDocumentToEvaluation", { + evaluation: val, + document: selectedDocumentToMove.value, + }); } }); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index ba762228f..87cd7565b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -259,12 +259,12 @@ function duplicateDocumentToEvaluation({ evaluation, document }) { } function moveDocumentToEvaluation({ evaluation, document }) { - const url = `/api/1.0/person/accompanying-course-work-evaluation-document/${document.id}/evaluation/${evaluation.id}/duplicate`; + const url = `/api/1.0/person/accompanying-course-work-evaluation-document/${document.id}/evaluation/${evaluation.id}/move`; // console.log('document id', document.id, 'evaluation id', evaluation.id) makeFetch("POST", url) .then((response) => { - console.log("new document", response); + console.log("document", response); toast.open({ message: trans(DOCUMENT_DUPLICATE_TO_EVALUATION_SUCCESS) }); }) .catch((error) => {