feat: filter assignments by status
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Assignment;
|
||||
use App\Entity\Destination;
|
||||
use App\Entity\JobProfile;
|
||||
use App\Model\AssignmentFilterDto;
|
||||
@@ -37,6 +38,15 @@ class AssignmentFilterType extends AbstractType
|
||||
'Mehr als einen Woche' => AssignmentFilterDto::DURATION_MORE,
|
||||
],
|
||||
])
|
||||
->add('status', ChoiceType::class, [
|
||||
'label' => 'Status',
|
||||
'required' => false,
|
||||
'choices' => [
|
||||
'Entwurf' => Assignment::STATUS_DRAFT,
|
||||
'offen' => Assignment::STATUS_OPEN,
|
||||
'geschlossen' => Assignment::STATUS_CLOSED,
|
||||
],
|
||||
])
|
||||
->add('apply', SubmitType::class, [
|
||||
'label' => 'filtern',
|
||||
])
|
||||
|
||||
@@ -17,6 +17,7 @@ class AssignmentFilterDto extends AbstractFilterDto
|
||||
protected ?JobProfile $jobProfile = null;
|
||||
protected ?Destination $destination = null;
|
||||
protected ?int $duration = null;
|
||||
protected ?string $status = null;
|
||||
|
||||
public function getDateFrom(): ?\DateTimeImmutable
|
||||
{
|
||||
@@ -77,4 +78,16 @@ class AssignmentFilterDto extends AbstractFilterDto
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStatus(): ?string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus(?string $status): static
|
||||
{
|
||||
$this->status = $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,13 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
|
||||
private function applyFilterSettings(AssignmentFilterDto $filterDto, QueryBuilder $qb): void
|
||||
{
|
||||
if (null !== $status = $filterDto->getStatus()) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->eq('assignment.status', ':status'))
|
||||
->setParameter('status', $status)
|
||||
;
|
||||
}
|
||||
|
||||
if (null !== $dateFrom = $filterDto->getDateFrom()) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->gte('destination.dateFrom', ':dateFrom'))
|
||||
|
||||
@@ -79,6 +79,9 @@ class AssignmentFilterHandler
|
||||
if (isset($data['duration']) && 0 < (int) $data['duration']) {
|
||||
$filterDto->setDuration($data['duration']);
|
||||
}
|
||||
if (isset($data['status'])) {
|
||||
$filterDto->setStatus($data['status']);
|
||||
}
|
||||
|
||||
return $filterDto;
|
||||
}
|
||||
@@ -91,6 +94,7 @@ class AssignmentFilterHandler
|
||||
'job_profile' => $filterDto->getJobProfile()?->getId(),
|
||||
'destination' => $filterDto->getDestination()?->getId(),
|
||||
'duration' => $filterDto->getDuration(),
|
||||
'status' => $filterDto->getStatus(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{{ form_start(filterForm) }}
|
||||
<div class="flex flex-col space-y-2 pb-2">
|
||||
{{ form_row(filterForm.status) }}
|
||||
{{ form_row(filterForm.dateFrom) }}
|
||||
{{ form_row(filterForm.dateTo) }}
|
||||
{{ form_row(filterForm.jobProfile) }}
|
||||
|
||||
Reference in New Issue
Block a user