From ec14320792da272a004d0cc89936d2b6c9c330ad Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Sun, 14 Dec 2025 08:44:45 +0200 Subject: [PATCH 1/2] Allow to mark multiple balloons as done --- .../src/Controller/Jury/BalloonController.php | 10 ++ webapp/src/Service/BalloonService.php | 21 +++- webapp/templates/jury/balloons.html.twig | 38 ++++++ .../jury/partials/balloon_list.html.twig | 116 ++++++++++-------- 4 files changed, 127 insertions(+), 58 deletions(-) diff --git a/webapp/src/Controller/Jury/BalloonController.php b/webapp/src/Controller/Jury/BalloonController.php index 9098772310..29e0962aeb 100644 --- a/webapp/src/Controller/Jury/BalloonController.php +++ b/webapp/src/Controller/Jury/BalloonController.php @@ -14,6 +14,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\ExpressionLanguage\Expression; use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -175,4 +176,13 @@ public function setDoneAction(int $balloonId, BalloonService $balloonService): R return $this->redirectToRoute("jury_balloons"); } + + #[Route(path: '/done', name: 'jury_balloons_setdone_multiple', methods: ['POST'])] + public function setMultipleDoneAction(Request $request, BalloonService $balloonService): RedirectResponse + { + $balloonIds = $request->request->all('balloonIds'); + $balloonService->setDone($balloonIds); + + return $this->redirectToRoute("jury_balloons"); + } } diff --git a/webapp/src/Service/BalloonService.php b/webapp/src/Service/BalloonService.php index 2b3dad6d13..c77f7d4ca4 100644 --- a/webapp/src/Service/BalloonService.php +++ b/webapp/src/Service/BalloonService.php @@ -181,14 +181,25 @@ public function collectBalloonTable(Contest $contest, bool $todo = false): array return $balloons_table; } - public function setDone(int $balloonId): void + /** + * @param int|list $balloonId + */ + public function setDone(int|array $balloonId): void { $em = $this->em; - $balloon = $em->getRepository(Balloon::class)->find($balloonId); - if (!$balloon) { - throw new NotFoundHttpException('balloon not found'); + $balloons = $em->createQueryBuilder() + ->from(Balloon::class, 'b') + ->select('b') + ->andWhere('b.balloonid IN (:balloonIds)') + ->setParameter('balloonIds', $balloonId) + ->getQuery() + ->getResult(); + if (empty($balloons)) { + throw new NotFoundHttpException('balloon(s) not found'); + } + foreach ($balloons as $balloon) { + $balloon->setDone(true); } - $balloon->setDone(true); $em->flush(); } } diff --git a/webapp/templates/jury/balloons.html.twig b/webapp/templates/jury/balloons.html.twig index 38d87c88fe..058f92b8a2 100644 --- a/webapp/templates/jury/balloons.html.twig +++ b/webapp/templates/jury/balloons.html.twig @@ -83,6 +83,16 @@ {% block extrafooter %} {% if current_contest is not null %}