Feat: Improve assignment filter ux

This commit is contained in:
Björn Fromme
2023-10-24 14:51:35 +02:00
parent d7d4e996bd
commit 51b2c9bb11
5 changed files with 68 additions and 48 deletions
@@ -10,6 +10,7 @@ use App\Service\Common\AssignmentFilterHandler;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
@@ -56,4 +57,13 @@ class AssignmentFilterController extends AbstractController
return $this->json($response);
}
#[Route('/common/assignment/filter/reset', name: 'app_common_assignment_filter_reset')]
public function reset(Request $request): Response
{
$this->filterHandler->resetFilterSettings();
$returnUrl = $this->getReturnUrl($request, 'app_admin_assignment_index');
return $this->redirect($returnUrl);
}
}
-6
View File
@@ -17,12 +17,6 @@ class AssignmentFilterDto
private ?JobProfile $jobProfile = null;
private ?Destination $destination = null;
private ?int $duration = null;
private bool $reset;
public function __construct(bool $reset = false)
{
$this->reset = $reset;
}
public function isActive(): bool
{
@@ -32,8 +32,8 @@ class AssignmentFilterHandler
$filterDto = $form->getData();
if ($form->get('reset')->isClicked()) {
$filterDto = new AssignmentFilterDto(true);
$this->getSession()->remove($this->namespace);
$filterDto = new AssignmentFilterDto();
$this->resetFilterSettings();
} elseif ($form->get('apply')->isClicked()) {
$this->saveFilterSettings($filterDto);
}
@@ -41,6 +41,11 @@ class AssignmentFilterHandler
return $filterDto;
}
public function resetFilterSettings(): void
{
$this->getSession()->remove($this->namespace);
}
public function getFilterSettings(): AssignmentFilterDto
{
if (null === $data = $this->getSession()->get($this->namespace)) {