From 51b2c9bb115ada388c72774188629cc72c1c8795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 24 Oct 2023 14:51:35 +0200 Subject: [PATCH] Feat: Improve assignment filter ux --- .../Common/AssignmentFilterController.php | 10 ++++ src/Model/AssignmentFilterDto.php | 6 --- .../Common/AssignmentFilterHandler.php | 9 +++- templates/admin/assignment/index.html.twig | 39 +++++++++----- templates/teamer/index.html.twig | 52 +++++++++---------- 5 files changed, 68 insertions(+), 48 deletions(-) diff --git a/src/Controller/Common/AssignmentFilterController.php b/src/Controller/Common/AssignmentFilterController.php index 52ba5f1..0476ef1 100644 --- a/src/Controller/Common/AssignmentFilterController.php +++ b/src/Controller/Common/AssignmentFilterController.php @@ -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); + } } \ No newline at end of file diff --git a/src/Model/AssignmentFilterDto.php b/src/Model/AssignmentFilterDto.php index dc2c3f9..bf8068d 100644 --- a/src/Model/AssignmentFilterDto.php +++ b/src/Model/AssignmentFilterDto.php @@ -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 { diff --git a/src/Service/Common/AssignmentFilterHandler.php b/src/Service/Common/AssignmentFilterHandler.php index 978caf8..de14b9f 100644 --- a/src/Service/Common/AssignmentFilterHandler.php +++ b/src/Service/Common/AssignmentFilterHandler.php @@ -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)) { diff --git a/templates/admin/assignment/index.html.twig b/templates/admin/assignment/index.html.twig index 585b5e7..f08012e 100644 --- a/templates/admin/assignment/index.html.twig +++ b/templates/admin/assignment/index.html.twig @@ -3,22 +3,33 @@ {% block title %}Einsatzübersicht{% endblock %} {% block content %} -
-

+
+

Einsatzübersicht

- +
+ + {% if filterDto.active %} + + Reset + + {% endif %} +
diff --git a/templates/teamer/index.html.twig b/templates/teamer/index.html.twig index 220ed27..bd5aed0 100644 --- a/templates/teamer/index.html.twig +++ b/templates/teamer/index.html.twig @@ -3,34 +3,34 @@ {% block title %}Einsatzübersicht{% endblock %} {% block content %} -
-

- Einsatzübersicht +
+

+ Einsatz­übersicht

- -
- {% if errors|length %} -
-
    - {% for error in errors %} -
  • - {{ error.message }} -
  • - {% endfor %} -
+
+ + {% if filterDto.active %} + + Reset + + {% endif %}
- {% endif %} +
{{ knp_pagination_render(pagination, 'paginator/sliding_boxes.html.twig') }}