Feat: Add teamer info popup

This commit is contained in:
Björn Fromme committed 2023-10-20 11:08:23 +02:00
1 parent 67cc7bf4ed
commit 2d657611fa
9 files changed
+137 -34

No files matched your search

+11 -1
View File
@@ -4,17 +4,27 @@ namespace App\Controller\Admin\Teamer;
use App\Entity\Teamer;
use App\Model\AjaxModalResponseDto;
use App\Repository\DispositionRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
class InfoController extends AbstractController
{
public function __construct(private readonly DispositionRepository $dispositionRepository)
{}
#[Route('/admin/teamer/info/{uuid}', name: 'app_admin_teamer_info')]
public function index(Teamer $teamer): JsonResponse
{
$response = new AjaxModalResponseDto();
$recentDispositions = $this->dispositionRepository->getRecentByTeamer($teamer);
$response = new AjaxModalResponseDto();
$response->setContent($this->renderView('admin/teamer/info.html.twig', [
'teamer' => $teamer,
'recentDispositions' => $recentDispositions,
]));
return $this->json($response);
}
}
+16 -1
View File
@@ -2,7 +2,6 @@
namespace App\Repository;
use App\Entity\Application;
use App\Entity\Assignment;
use App\Entity\Disposition;
use App\Entity\Teamer;
@@ -94,4 +93,20 @@ class DispositionRepository extends ServiceEntityRepository
->getResult()
;
}
public function getRecentByTeamer(Teamer $teamer, int $limit = 5): array
{
$qb = $this->createQueryBuilder('disposition');
return $qb
->select('disposition', 'assignment', 'destination')
->innerJoin('disposition.assignment', 'assignment')
->innerJoin('assignment.destination', 'destination')
->where($qb->expr()->eq('disposition.teamer', ':teamer'))
->setParameter('teamer', $teamer)
->orderBy('destination.dateFrom', 'DESC')
->getQuery()
->getResult()
;
}
}