From 67cc7bf4ed238ec68042ed177afbc0a1e9bbcbd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 19 Oct 2023 15:49:26 +0200 Subject: [PATCH] Feat: Add popup window to display teamer info per application --- .../Admin/Application/InfoController.php | 23 ++++++++++++++ .../Admin/Teamer/InfoController.php | 20 ++++++++++++ src/Controller/Common/DownloadController.php | 8 +++-- src/Entity/Application.php | 4 +-- .../_assignment_requirements_info.html.twig | 24 +++++++------- templates/admin/application/index.html.twig | 14 +++++++-- templates/admin/application/info.html.twig | 31 +++++++++++++++++++ templates/admin/document/index.html.twig | 3 +- 8 files changed, 107 insertions(+), 20 deletions(-) create mode 100644 src/Controller/Admin/Application/InfoController.php create mode 100644 src/Controller/Admin/Teamer/InfoController.php create mode 100644 templates/admin/application/info.html.twig diff --git a/src/Controller/Admin/Application/InfoController.php b/src/Controller/Admin/Application/InfoController.php new file mode 100644 index 0000000..1f97361 --- /dev/null +++ b/src/Controller/Admin/Application/InfoController.php @@ -0,0 +1,23 @@ +setContent($this->renderView('admin/application/info.html.twig', [ + 'application' => $application, + ])); + + return $this->json($response); + } +} \ No newline at end of file diff --git a/src/Controller/Admin/Teamer/InfoController.php b/src/Controller/Admin/Teamer/InfoController.php new file mode 100644 index 0000000..a02f115 --- /dev/null +++ b/src/Controller/Admin/Teamer/InfoController.php @@ -0,0 +1,20 @@ +json($response); + } +} \ No newline at end of file diff --git a/src/Controller/Common/DownloadController.php b/src/Controller/Common/DownloadController.php index 78cf40c..015eb1a 100644 --- a/src/Controller/Common/DownloadController.php +++ b/src/Controller/Common/DownloadController.php @@ -5,7 +5,9 @@ namespace App\Controller\Common; use App\Entity\Upload; use App\Service\Upload\UploadHandler; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\ResponseHeaderBag; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -17,11 +19,13 @@ class DownloadController extends AbstractController #[Route('/download/{uuid}', name: 'app_common_download')] #[IsGranted('DOWNLOAD', subject: 'upload')] - public function index(Upload $upload): Response + public function index(Upload $upload, Request $request): Response { $path = $this->uploadHandler->getUploadFilepath($upload); $originalFilename = $upload->getOriginalFilename(); + $inline = (bool) $request->get('inline'); + $disposition = $inline ? ResponseHeaderBag::DISPOSITION_INLINE : ResponseHeaderBag::DISPOSITION_ATTACHMENT; - return $this->file($path, $originalFilename); + return $this->file($path, $originalFilename, $disposition); } } \ No newline at end of file diff --git a/src/Entity/Application.php b/src/Entity/Application.php index bc4e539..3b342d7 100644 --- a/src/Entity/Application.php +++ b/src/Entity/Application.php @@ -129,7 +129,7 @@ class Application implements TimestampableEntityInterface return $teamer->hasPickup($pickupId); } - public function getCompletedTrainingsCount(): int + public function matchesRequiredTrainings(): bool { $count = 0; $requiredTrainings = $this->getAssignment()->getJobProfile()->getRequiredTrainings(); @@ -141,6 +141,6 @@ class Application implements TimestampableEntityInterface } } - return $count; + return $count === $requiredTrainings->count(); } } diff --git a/templates/_partials/_assignment_requirements_info.html.twig b/templates/_partials/_assignment_requirements_info.html.twig index 06327d4..472fc99 100644 --- a/templates/_partials/_assignment_requirements_info.html.twig +++ b/templates/_partials/_assignment_requirements_info.html.twig @@ -1,24 +1,24 @@ -