From 9a572cf3cb7b0b194139b95516989ac3ababe863 Mon Sep 17 00:00:00 2001 From: Iris Olfermann Date: Mon, 26 Aug 2024 13:43:38 +0200 Subject: [PATCH] enabled deleting of events and updated the frontend to always show two empty boxes for events --- .../Controller/MealAdminController.php | 18 ++++++++++++------ src/Resources/src/components/menu/MenuDay.vue | 7 ++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Mealz/MealBundle/Controller/MealAdminController.php b/src/Mealz/MealBundle/Controller/MealAdminController.php index eaca69968..2ee7d93de 100644 --- a/src/Mealz/MealBundle/Controller/MealAdminController.php +++ b/src/Mealz/MealBundle/Controller/MealAdminController.php @@ -304,12 +304,18 @@ private function handleEventArr(array $eventArr, Day $day): void{ private function addEvent(array $event, Day $dayEntity){ $this->logger->info('EventId: '. $event['eventId']. ', name: '. $event['eventSlug']); - $eventEntity = $this->mealAdminHelper->findEvent($event['eventId']); - $eventExistsForDayAlready = $this->mealAdminHelper->checkIfEventExistsForDay($event['eventId'], $dayEntity); - if(!$eventExistsForDayAlready){ - $this->logger->info('addEvent'); - $eventParticipationEntity = new EventParticipation($dayEntity, $eventEntity); - $dayEntity->addEvent($eventParticipationEntity); + if(!isset($event['eventId'])){ + $this->logger->info('Event wird gelöscht'); + } else{ + $eventEntity = $this->mealAdminHelper->findEvent($event['eventId']); + $eventExistsForDayAlready = $this->mealAdminHelper->checkIfEventExistsForDay($event['eventId'], $dayEntity); + if(!$eventExistsForDayAlready){ + $this->logger->info('addEvent'); + $eventParticipationEntity = new EventParticipation($dayEntity, $eventEntity); + $dayEntity->addEvent($eventParticipationEntity); + } else{ + throw new Exception('Meal exists for day already'); + } } } diff --git a/src/Resources/src/components/menu/MenuDay.vue b/src/Resources/src/components/menu/MenuDay.vue index 435945662..96e65e93e 100644 --- a/src/Resources/src/components/menu/MenuDay.vue +++ b/src/Resources/src/components/menu/MenuDay.vue @@ -1,11 +1,9 @@