feat: filter for feedbacks, code cleanup

This commit is contained in:
Björn Fromme committed 2024-10-28 16:19:45 +01:00
1 parent 49faa1eb25
commit a8ccdc8775
11 files changed
+297 -27

No files matched your search

@@ -3,6 +3,7 @@
namespace App\Controller\Administrative\Feedback;
use App\Repository\FeedbackRepository;
use App\Service\Common\FeedbackFilterHandler;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -13,6 +14,7 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController
{
public function __construct(
private readonly FeedbackFilterHandler $filterHandler,
private readonly FeedbackRepository $feedbackRepository,
private readonly PaginatorInterface $paginator
) {
@@ -22,9 +24,11 @@ class IndexController extends AbstractController
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response
{
$filterDto = $this->filterHandler->getFilterSettings();
$query = $this
->feedbackRepository
->getListQuery()
->getListQuery($filterDto)
;
$pagination = $this->paginator->paginate(
@@ -39,6 +43,7 @@ class IndexController extends AbstractController
return $this->render('administrative/feedback/index.html.twig', [
'pagination' => $pagination,
'filterDto' => $filterDto,
]);
}
}
@@ -2,7 +2,6 @@
namespace App\Controller\Common;
use App\Controller\Traits\ReturnUrlTrait;
use App\Form\AssignmentFilterType;
use App\Htmx\HxRedirectResponse;
use App\Repository\AssignmentRepository;
@@ -15,8 +14,6 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
class AssignmentFilterController extends AbstractController
{
use ReturnUrlTrait;
public function __construct(
private readonly AssignmentFilterHandler $filterHandler,
private readonly AssignmentRepository $assignmentRepository
@@ -40,7 +37,7 @@ class AssignmentFilterController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$this->filterHandler->handleRequest($form);
$returnUrl = $this->getReturnUrl($request, 'app_administrative_assignment_index');
$returnUrl = $this->generateUrl('app_administrative_assignment_index');
return new HxRedirectResponse($returnUrl);
}
@@ -55,7 +52,7 @@ class AssignmentFilterController extends AbstractController
public function reset(Request $request): Response
{
$this->filterHandler->resetFilterSettings();
$returnUrl = $this->getReturnUrl($request, 'app_administrative_assignment_index');
$returnUrl = $this->generateUrl('app_administrative_assignment_index');
return $this->redirect($returnUrl);
}
@@ -2,7 +2,6 @@
namespace App\Controller\Common;
use App\Controller\Traits\ReturnUrlTrait;
use App\Form\DocumentFilterType;
use App\Htmx\HxRedirectResponse;
use App\Service\Common\DocumentFilterHandler;
@@ -14,11 +13,8 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
class DocumentFilterController extends AbstractController
{
use ReturnUrlTrait;
public function __construct(
private readonly DocumentFilterHandler $filterHandler
) {
public function __construct(private readonly DocumentFilterHandler $filterHandler)
{
}
#[Route('/common/document/filter', name: 'app_common_document_filter')]
@@ -32,7 +28,7 @@ class DocumentFilterController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$this->filterHandler->handleRequest($form);
$returnUrl = $this->getReturnUrl($request, 'app_administrative_document_index');
$returnUrl = $this->generateUrl('app_administrative_document_index');
return new HxRedirectResponse($returnUrl);
}
@@ -47,7 +43,7 @@ class DocumentFilterController extends AbstractController
public function reset(Request $request): Response
{
$this->filterHandler->resetFilterSettings();
$returnUrl = $this->getReturnUrl($request, 'app_administrative_document_index');
$returnUrl = $this->generateUrl('app_administrative_document_index');
return $this->redirect($returnUrl);
}
@@ -0,0 +1,49 @@
<?php
namespace App\Controller\Common;
use App\Form\FeedbackFilterType;
use App\Htmx\HxRedirectResponse;
use App\Service\Common\FeedbackFilterHandler;
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 FeedbackFilterController extends AbstractController
{
public function __construct(private readonly FeedbackFilterHandler $filterHandler)
{
}
#[Route('/common/feedback/filter', name: 'app_common_feedback_filter')]
#[IsGranted('ROLE_USER')]
public function index(Request $request): Response
{
$formData = $this->filterHandler->getFilterSettings();
$form = $this->createForm(FeedbackFilterType::class, $formData);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->filterHandler->handleRequest($form);
$returnUrl = $this->generateUrl('app_administrative_feedback_index');
return new HxRedirectResponse($returnUrl);
}
return $this->render('common/modal_feedback_filter.html.twig', [
'filterForm' => $form->createView(),
'filterDto' => $form->getData(),
]);
}
#[Route('/common/feedback/filter/reset', name: 'app_common_feedback_filter_reset')]
public function reset(Request $request): Response
{
$this->filterHandler->resetFilterSettings();
$returnUrl = $this->generateUrl('app_administrative_feedback_index');
return $this->redirect($returnUrl);
}
}
@@ -2,10 +2,8 @@
namespace App\Controller\Common;
use App\Controller\Traits\ReturnUrlTrait;
use App\Form\TeamerFilterType;
use App\Htmx\HxRedirectResponse;
use App\Repository\TeamerRepository;
use App\Service\Common\TeamerFilterHandler;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -15,12 +13,8 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
class TeamerFilterController extends AbstractController
{
use ReturnUrlTrait;
public function __construct(
private readonly TeamerFilterHandler $filterHandler,
private readonly TeamerRepository $teamerRepository
) {
public function __construct(private readonly TeamerFilterHandler $filterHandler)
{
}
#[Route('/common/teamer/filter', name: 'app_common_teamer_filter')]
@@ -33,7 +27,7 @@ class TeamerFilterController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$this->filterHandler->handleRequest($form);
$returnUrl = $this->getReturnUrl($request, 'app_administrative_teamer_index');
$returnUrl = $this->generateUrl('app_administrative_teamer_index');
return new HxRedirectResponse($returnUrl);
}
@@ -48,7 +42,7 @@ class TeamerFilterController extends AbstractController
public function reset(Request $request): Response
{
$this->filterHandler->resetFilterSettings();
$returnUrl = $this->getReturnUrl($request, 'app_administrative_teamer_index');
$returnUrl = $this->generateUrl('app_administrative_teamer_index');
return $this->redirect($returnUrl);
}