Feat: Add assignment filtering for teamers

This commit is contained in:
Björn Fromme
2023-10-23 15:45:41 +02:00
parent dcf0d9af20
commit ae81c97d12
7 changed files with 88 additions and 56 deletions
+11 -2
View File
@@ -4,6 +4,7 @@ namespace App\Controller\Teamer;
use App\Entity\User;
use App\Repository\AssignmentRepository;
use App\Service\Common\AssignmentFilterHandler;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -16,6 +17,7 @@ class IndexController extends AbstractController
{
public function __construct(
private readonly ValidatorInterface $validator,
private readonly AssignmentFilterHandler $filterHandler,
private readonly PaginatorInterface $paginator,
private readonly AssignmentRepository $assignmentRepository
) {
@@ -32,9 +34,15 @@ class IndexController extends AbstractController
// Validate teamer data to show missing data right away
$errors = $this->validator->validate($teamer, null, ['profile_preflight']);
$filterForm = $this->filterHandler->getForm('assignment_filter_teamer');
$filterDto = $this->filterHandler->handleRequest($filterForm, $request, 'assignment_filter_teamer');
if (true === $filterDto->isReset()) {
return $this->redirectToRoute('app_teamer_index');
}
$query = $this
->assignmentRepository
->getListQueryForTeamer($teamer)
->getListQueryForTeamer($teamer, $filterDto)
;
$pagination = $this->paginator->paginate(
@@ -49,8 +57,9 @@ class IndexController extends AbstractController
return $this->render('teamer/index.html.twig', [
'teamer' => $teamer,
'pagination' => $pagination,
'errors' => $errors,
'pagination' => $pagination,
'filterForm' => $filterForm,
]);
}
}