feat: hide past assignments by default, include via filtersetting
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Model\AssignmentFilterDto;
|
|||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
@@ -51,6 +52,10 @@ class AssignmentFilterType extends AbstractType
|
|||||||
'Mehr als einen Woche' => AssignmentFilterDto::DURATION_MORE,
|
'Mehr als einen Woche' => AssignmentFilterDto::DURATION_MORE,
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
|
->add('includePast', CheckboxType::class, [
|
||||||
|
'label' => 'vergangene Einsätze anzeigen',
|
||||||
|
'required' => false,
|
||||||
|
])
|
||||||
->add('apply', SubmitType::class, [
|
->add('apply', SubmitType::class, [
|
||||||
'label' => 'filtern',
|
'label' => 'filtern',
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class AssignmentFilterDto extends AbstractFilterDto
|
|||||||
protected ?string $hotel = null;
|
protected ?string $hotel = null;
|
||||||
protected ?int $duration = null;
|
protected ?int $duration = null;
|
||||||
protected ?string $status = null;
|
protected ?string $status = null;
|
||||||
|
protected bool $includePast = false;
|
||||||
|
|
||||||
public function getDateFrom(): ?\DateTimeImmutable
|
public function getDateFrom(): ?\DateTimeImmutable
|
||||||
{
|
{
|
||||||
@@ -90,4 +91,16 @@ class AssignmentFilterDto extends AbstractFilterDto
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isIncludePast(): bool
|
||||||
|
{
|
||||||
|
return $this->includePast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIncludePast(bool $includePast): static
|
||||||
|
{
|
||||||
|
$this->includePast = $includePast;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -110,6 +110,13 @@ class AssignmentRepository extends ServiceEntityRepository
|
|||||||
|
|
||||||
private function applyFilterSettings(AssignmentFilterDto $filterDto, QueryBuilder $qb): void
|
private function applyFilterSettings(AssignmentFilterDto $filterDto, QueryBuilder $qb): void
|
||||||
{
|
{
|
||||||
|
if (false === $filterDto->isIncludePast()) {
|
||||||
|
$qb
|
||||||
|
->andWhere($qb->expr()->gte('destination.dateFrom', ':now'))
|
||||||
|
->setParameter('now', new \DateTimeImmutable())
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== $status = $filterDto->getStatus()) {
|
if (null !== $status = $filterDto->getStatus()) {
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case Assignment::STATUS_STAFFED:
|
case Assignment::STATUS_STAFFED:
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ class AssignmentFilterHandler
|
|||||||
if (isset($data['status'])) {
|
if (isset($data['status'])) {
|
||||||
$filterDto->setStatus($data['status']);
|
$filterDto->setStatus($data['status']);
|
||||||
}
|
}
|
||||||
|
if (isset($data['include_past'])) {
|
||||||
|
$filterDto->setIncludePast((bool) $data['include_past']);
|
||||||
|
}
|
||||||
|
|
||||||
return $filterDto;
|
return $filterDto;
|
||||||
}
|
}
|
||||||
@@ -89,6 +92,7 @@ class AssignmentFilterHandler
|
|||||||
'hotel' => $filterDto->getHotel(),
|
'hotel' => $filterDto->getHotel(),
|
||||||
'duration' => $filterDto->getDuration(),
|
'duration' => $filterDto->getDuration(),
|
||||||
'status' => $filterDto->getStatus(),
|
'status' => $filterDto->getStatus(),
|
||||||
|
'include_past' => $filterDto->isIncludePast(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
{{ form_row(filterForm.jobProfile) }}
|
{{ form_row(filterForm.jobProfile) }}
|
||||||
{{ form_row(filterForm.hotel) }}
|
{{ form_row(filterForm.hotel) }}
|
||||||
{{ form_row(filterForm.duration) }}
|
{{ form_row(filterForm.duration) }}
|
||||||
|
{{ form_row(filterForm.includePast) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center space-x-2">
|
<div class="flex items-center space-x-2">
|
||||||
{{ form_widget(filterForm.apply, { 'attr': { 'class': 'btn' } }) }}
|
{{ form_widget(filterForm.apply, { 'attr': { 'class': 'btn' } }) }}
|
||||||
|
|||||||
Reference in New Issue
Block a user