Feat: Add popup window to display teamer info per application

This commit is contained in:
Björn Fromme
2023-10-19 15:49:26 +02:00
parent 585f86e45f
commit 67cc7bf4ed
8 changed files with 107 additions and 20 deletions
@@ -0,0 +1,23 @@
<?php
namespace App\Controller\Admin\Application;
use App\Entity\Application;
use App\Model\AjaxModalResponseDto;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
class InfoController extends AbstractController
{
#[Route('/admin/application/info/{uuid}', name: 'app_admin_application_info')]
public function index(Application $application): JsonResponse
{
$response = new AjaxModalResponseDto();
$response->setContent($this->renderView('admin/application/info.html.twig', [
'application' => $application,
]));
return $this->json($response);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Controller\Admin\Teamer;
use App\Entity\Teamer;
use App\Model\AjaxModalResponseDto;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
class InfoController extends AbstractController
{
#[Route('/admin/teamer/info/{uuid}', name: 'app_admin_teamer_info')]
public function index(Teamer $teamer): JsonResponse
{
$response = new AjaxModalResponseDto();
return $this->json($response);
}
}
+6 -2
View File
@@ -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);
}
}
+2 -2
View File
@@ -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();
}
}