feat: filtering of custom destinations by hotel

This commit is contained in:
Björn Fromme
2025-07-22 17:42:06 +02:00
parent ea574427fb
commit e0ce495b86
8 changed files with 233 additions and 1 deletions
@@ -3,6 +3,7 @@
namespace App\Controller\Administrative\System\Destination;
use App\Repository\DestinationRepository;
use App\Service\Common\DestinationFilterHandler;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -15,6 +16,7 @@ class IndexController extends AbstractController
public function __construct(
private readonly DestinationRepository $destinationRepository,
private readonly PaginatorInterface $paginator,
private readonly DestinationFilterHandler $filterHandler
) {
}
@@ -22,9 +24,11 @@ class IndexController extends AbstractController
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response
{
$filterDto = $this->filterHandler->getFilterSettings();
$query = $this
->destinationRepository
->getListQueryForCustom()
->getListQuery($filterDto)
;
$pagination = $this->paginator->paginate(
@@ -39,6 +43,7 @@ class IndexController extends AbstractController
return $this->render('administrative/system/destination/index.html.twig', [
'pagination' => $pagination,
'filterDto' => $filterDto,
]);
}
}
@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace App\Controller\Common;
use App\Controller\Traits\ReturnUrlTrait;
use App\Form\DestinationFilterType;
use App\Htmx\HxRedirectResponse;
use App\Service\Common\DestinationFilterHandler;
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 DestinationFilterController extends AbstractController
{
use ReturnUrlTrait;
public function __construct(
private readonly DestinationFilterHandler $filterHandler
) {
}
#[Route('/common/destination/filter', name: 'app_common_destination_filter')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response
{
$formData = $this->filterHandler->getFilterSettings();
$form = $this->createForm(DestinationFilterType::class, $formData);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->filterHandler->handleRequest($form);
$returnUrl = $this->getReturnUrl($request, 'app_administrative_system_destination_index');
return new HxRedirectResponse($returnUrl);
}
return $this->render('common/modal_destination_filter.html.twig', [
'filterForm' => $form->createView(),
'filterDto' => $form->getData(),
]);
}
#[Route('/common/destination/filter/reset', name: 'app_common_destination_filter_reset')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function reset(Request $request): Response
{
$this->filterHandler->resetFilterSettings();
$returnUrl = $this->getReturnUrl($request, 'app_administrative_system_destination_index');
return $this->redirect($returnUrl);
}
}