Skip to content

Commit

Permalink
enabled deleting of events and updated the frontend to always show tw…
Browse files Browse the repository at this point in the history
…o empty boxes for events
  • Loading branch information
IrisOlfermann committed Aug 26, 2024
1 parent db1370c commit 9a572cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
18 changes: 12 additions & 6 deletions src/Mealz/MealBundle/Controller/MealAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Check warning on line 311 in src/Mealz/MealBundle/Controller/MealAdminController.php

View workflow job for this annotation

GitHub Actions / PHPMD

Avoid excessively long variable names like $eventExistsForDayAlready. Keep variable name length under 20.
if(!$eventExistsForDayAlready){
$this->logger->info('addEvent');
$eventParticipationEntity = new EventParticipation($dayEntity, $eventEntity);

Check warning on line 314 in src/Mealz/MealBundle/Controller/MealAdminController.php

View workflow job for this annotation

GitHub Actions / PHPMD

Avoid excessively long variable names like $eventParticipationEntity. Keep variable name length under 20.
$dayEntity->addEvent($eventParticipationEntity);
} else{
throw new Exception('Meal exists for day already');
}
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/Resources/src/components/menu/MenuDay.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<template>
<div
class="day-shadow group grid grid-cols-[24px_minmax(0,1fr)_58px] rounded-lg border-0 border-none bg-white text-center align-middle sm:grid-cols-[24px_minmax(0,1fr)_72px]"
:class="[selectedEventOne ? 'grid-rows-4' : 'grid-rows-3']"
class="day-shadow group grid grid-cols-[24px_minmax(0,1fr)_58px] grid-rows-4 rounded-lg border-0 border-none bg-white text-center align-middle sm:grid-cols-[24px_minmax(0,1fr)_72px]"
>
<div
class="col-start-1 row-start-1 grid w-[24px] grid-rows-[24px_minmax(0,1fr)_24px] justify-center rounded-l-lg bg-primary-2 py-1"
:class="[selectedEventOne ? 'row-span-4' : 'row-span-3']"
class="col-start-1 row-span-4 row-start-1 grid w-[24px] grid-rows-[24px_minmax(0,1fr)_24px] justify-center rounded-l-lg bg-primary-2 py-1"
>
<Popover
:translate-x-min="'0%'"
Expand Down Expand Up @@ -50,7 +48,6 @@
class="col-start-2 row-span-1 row-start-3 border-b border-t-[3px] px-2 py-[12px] md:px-4"
/>
<EventInput
v-if="selectedEventOne"
v-model="selectedEventTwo"
class="col-start-2 row-span-1 row-start-4 px-2 py-[12px] md:px-4"
/>
Expand Down

0 comments on commit 9a572cf

Please sign in to comment.