diff --git a/src/Controller/Teamer/IndexController.php b/src/Controller/Teamer/IndexController.php index 486d81a..92d0b3d 100644 --- a/src/Controller/Teamer/IndexController.php +++ b/src/Controller/Teamer/IndexController.php @@ -60,6 +60,7 @@ class IndexController extends AbstractController 'errors' => $errors, 'pagination' => $pagination, 'filterForm' => $filterForm, + 'filterDto' => $filterDto, ]); } } \ No newline at end of file diff --git a/src/Model/AssignmentFilterDto.php b/src/Model/AssignmentFilterDto.php index 047cd78..dc2c3f9 100644 --- a/src/Model/AssignmentFilterDto.php +++ b/src/Model/AssignmentFilterDto.php @@ -24,6 +24,27 @@ class AssignmentFilterDto $this->reset = $reset; } + public function isActive(): bool + { + return $this->getActiveFiltersCount() > 0; + } + + public function getActiveFiltersCount(): int + { + $freshInstance = new static(); + $filterCount = 0; + $reflection = new \ReflectionClass(static::class); + + foreach ($reflection->getProperties() as $property) { + $name = $property->getName(); + if ($this->$name !== $freshInstance->$name) { + ++$filterCount; + } + } + + return $filterCount; + } + public function getDateFrom(): ?\DateTimeImmutable { return $this->dateFrom; diff --git a/templates/teamer/index.html.twig b/templates/teamer/index.html.twig index 510f211..6a06d98 100644 --- a/templates/teamer/index.html.twig +++ b/templates/teamer/index.html.twig @@ -19,24 +19,32 @@ {% endif %} {{ form_start(filterForm) }} -