feat: add filtering of applications

This commit is contained in:
Björn Fromme
2025-02-10 17:08:42 +01:00
parent 2c189de0c7
commit 3e2c5976aa
8 changed files with 514 additions and 7 deletions
@@ -3,6 +3,7 @@
namespace App\Controller\Admin\Application;
use App\Repository\ApplicationRepository;
use App\Service\Common\ApplicationFilterHandler;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -14,7 +15,8 @@ class IndexController extends AbstractController
{
public function __construct(
private readonly ApplicationRepository $applicationRepository,
private readonly PaginatorInterface $paginator
private readonly PaginatorInterface $paginator,
private readonly ApplicationFilterHandler $filterHandler,
) {
}
@@ -22,9 +24,11 @@ class IndexController extends AbstractController
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response
{
$filterDto = $this->filterHandler->getFilterSettings();
$query = $this
->applicationRepository
->getPendingQuery()
->getPendingQuery($filterDto);
;
$pagination = $this->paginator->paginate(
@@ -39,6 +43,7 @@ class IndexController extends AbstractController
return $this->render('admin/application/index.html.twig', [
'pagination' => $pagination,
'filterDto' => $filterDto,
]);
}
}
@@ -0,0 +1,64 @@
<?php
namespace App\Controller\Common;
use App\Controller\Traits\ReturnUrlTrait;
use App\Form\ApplicationFilterType;
use App\Htmx\HxRedirectResponse;
use App\Repository\ApplicationRepository;
use App\Repository\AssignmentRepository;
use App\Service\Common\ApplicationFilterHandler;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class ApplicationFilterController extends AbstractController
{
use ReturnUrlTrait;
public function __construct(
private readonly ApplicationFilterHandler $filterHandler,
private readonly ApplicationRepository $applicationRepository,
private readonly AssignmentRepository $assignmentRepository,
) {
}
#[Route('/common/application/filter', name: 'app_common_application_filter')]
#[IsGranted('ROLE_USER')]
public function index(Request $request): Response
{
$formData = $this->filterHandler->getFilterSettings();
$filterOptions = $this->assignmentRepository->getFilterOptions();
$formOptions = [
'min_date' => $filterOptions['minDate'],
'max_date' => $filterOptions['maxDate'],
'job_profiles' => $filterOptions['jobProfiles'],
];
$form = $this->createForm(ApplicationFilterType::class, $formData, $formOptions);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->filterHandler->handleRequest($form);
$returnUrl = $this->getReturnUrl($request, 'app_admin_application_index');
return new HxRedirectResponse($returnUrl);
}
return $this->render('common/modal_application_filter.html.twig', [
'filterForm' => $form->createView(),
'filterDto' => $form->getData(),
]);
}
#[Route('/common/application/filter/reset', name: 'app_common_application_filter_reset')]
public function reset(Request $request): Response
{
$this->filterHandler->resetFilterSettings();
$returnUrl = $this->getReturnUrl($request, 'app_admin_application_index');
return $this->redirect($returnUrl);
}
}