feat: filter assignments by id
This commit is contained in:
@@ -12,6 +12,7 @@ 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\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||||
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;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
@@ -27,6 +28,7 @@ class AssignmentFilterType extends AbstractType
|
|||||||
$builder
|
$builder
|
||||||
->add('dateFrom', DatepickerType::class, [
|
->add('dateFrom', DatepickerType::class, [
|
||||||
'label' => 'Zeitraum von',
|
'label' => 'Zeitraum von',
|
||||||
|
'required' => false,
|
||||||
'min_date' => $options['min_date'],
|
'min_date' => $options['min_date'],
|
||||||
'max_date' => $options['max_date'],
|
'max_date' => $options['max_date'],
|
||||||
'attr' => [
|
'attr' => [
|
||||||
@@ -35,6 +37,7 @@ class AssignmentFilterType extends AbstractType
|
|||||||
])
|
])
|
||||||
->add('dateTo', DatepickerType::class, [
|
->add('dateTo', DatepickerType::class, [
|
||||||
'label' => 'Zeitraum bis',
|
'label' => 'Zeitraum bis',
|
||||||
|
'required' => false,
|
||||||
'min_date' => $options['min_date'],
|
'min_date' => $options['min_date'],
|
||||||
'max_date' => $options['max_date'],
|
'max_date' => $options['max_date'],
|
||||||
'attr' => [
|
'attr' => [
|
||||||
@@ -65,7 +68,12 @@ class AssignmentFilterType extends AbstractType
|
|||||||
;
|
;
|
||||||
|
|
||||||
if ($this->security->isGranted('ROLE_ADMINISTRATIVE')) {
|
if ($this->security->isGranted('ROLE_ADMINISTRATIVE')) {
|
||||||
$builder->add('status', MultiselectType::class, [
|
$builder
|
||||||
|
->add('id', IntegerType::class, [
|
||||||
|
'label' => 'ID',
|
||||||
|
'required' => false,
|
||||||
|
])
|
||||||
|
->add('status', MultiselectType::class, [
|
||||||
'label' => 'Status',
|
'label' => 'Status',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'empty_label' => 'nicht filtern',
|
'empty_label' => 'nicht filtern',
|
||||||
@@ -75,7 +83,8 @@ class AssignmentFilterType extends AbstractType
|
|||||||
'unbesetzt' => Assignment::STATUS_UNSTAFFED,
|
'unbesetzt' => Assignment::STATUS_UNSTAFFED,
|
||||||
'mit Bewerbungen' => Assignment::STATUS_STAFFING,
|
'mit Bewerbungen' => Assignment::STATUS_STAFFING,
|
||||||
],
|
],
|
||||||
]);
|
])
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < count($options['job_profiles'])) {
|
if (0 < count($options['job_profiles'])) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class AssignmentFilterDto extends AbstractFilterDto
|
|||||||
public const DURATION_FULL_WEEK = 3;
|
public const DURATION_FULL_WEEK = 3;
|
||||||
public const DURATION_MORE = 4;
|
public const DURATION_MORE = 4;
|
||||||
|
|
||||||
|
protected ?int $id = null;
|
||||||
protected ?\DateTimeImmutable $dateFrom = null;
|
protected ?\DateTimeImmutable $dateFrom = null;
|
||||||
protected ?\DateTimeImmutable $dateTo = null;
|
protected ?\DateTimeImmutable $dateTo = null;
|
||||||
protected array $jobProfiles = [];
|
protected array $jobProfiles = [];
|
||||||
@@ -20,6 +21,18 @@ class AssignmentFilterDto extends AbstractFilterDto
|
|||||||
protected array $status = [];
|
protected array $status = [];
|
||||||
protected bool $includePast = false;
|
protected bool $includePast = false;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setId(?int $id): static
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDateFrom(): ?\DateTimeImmutable
|
public function getDateFrom(): ?\DateTimeImmutable
|
||||||
{
|
{
|
||||||
return $this->dateFrom;
|
return $this->dateFrom;
|
||||||
|
|||||||
@@ -85,6 +85,13 @@ class AssignmentRepository extends ServiceEntityRepository
|
|||||||
|
|
||||||
private function applyFilterSettings(AssignmentFilterDto $filterDto, QueryBuilder $qb): void
|
private function applyFilterSettings(AssignmentFilterDto $filterDto, QueryBuilder $qb): void
|
||||||
{
|
{
|
||||||
|
if (null !== $filterDto->getId()) {
|
||||||
|
$qb
|
||||||
|
->andWhere($qb->expr()->eq('assignment.id', ':id'))
|
||||||
|
->setParameter('id', $filterDto->getId())
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
if (false === $filterDto->isIncludePast()) {
|
if (false === $filterDto->isIncludePast()) {
|
||||||
$qb
|
$qb
|
||||||
->andWhere($qb->expr()->gte('destination.dateFrom', ':now'))
|
->andWhere($qb->expr()->gte('destination.dateFrom', ':now'))
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ class AssignmentFilterHandler extends AbstractFilterHandler
|
|||||||
|
|
||||||
$filterDto = new AssignmentFilterDto();
|
$filterDto = new AssignmentFilterDto();
|
||||||
|
|
||||||
|
if (isset($data['id'])) {
|
||||||
|
$filterDto->setId($data['id']);
|
||||||
|
}
|
||||||
if (isset($data['date_from'])) {
|
if (isset($data['date_from'])) {
|
||||||
$filterDto->setDateFrom($data['date_from']);
|
$filterDto->setDateFrom($data['date_from']);
|
||||||
}
|
}
|
||||||
@@ -52,6 +55,7 @@ class AssignmentFilterHandler extends AbstractFilterHandler
|
|||||||
{
|
{
|
||||||
/** @var AssignmentFilterDto $filterDto */
|
/** @var AssignmentFilterDto $filterDto */
|
||||||
$this->getSession()->set($this->namespace, [
|
$this->getSession()->set($this->namespace, [
|
||||||
|
'id' => $filterDto->getId(),
|
||||||
'date_from' => $filterDto->getDateFrom(),
|
'date_from' => $filterDto->getDateFrom(),
|
||||||
'date_to' => $filterDto->getDateTo(),
|
'date_to' => $filterDto->getDateTo(),
|
||||||
'job_profiles' => array_map(function (JobProfile $jobProfile) {
|
'job_profiles' => array_map(function (JobProfile $jobProfile) {
|
||||||
|
|||||||
@@ -5,11 +5,16 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
{{ form_start(filterForm, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }}
|
{{ form_start(filterForm, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }}
|
||||||
<div class="flex flex-col space-y-2 pb-4">
|
<div class="flex flex-col space-y-2 pb-4">
|
||||||
|
{% if filterForm.id is defined %}
|
||||||
|
{{ form_row(filterForm.id) }}
|
||||||
|
{% endif %}
|
||||||
{% if filterForm.status is defined %}
|
{% if filterForm.status is defined %}
|
||||||
{{ form_row(filterForm.status) }}
|
{{ form_row(filterForm.status) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="grid grid-cols-2 gap-x-4 gap-y-2">
|
||||||
{{ form_row(filterForm.dateFrom) }}
|
{{ form_row(filterForm.dateFrom) }}
|
||||||
{{ form_row(filterForm.dateTo) }}
|
{{ form_row(filterForm.dateTo) }}
|
||||||
|
</div>
|
||||||
{{ form_row(filterForm.jobProfiles) }}
|
{{ form_row(filterForm.jobProfiles) }}
|
||||||
{{ form_row(filterForm.hotels) }}
|
{{ form_row(filterForm.hotels) }}
|
||||||
{{ form_row(filterForm.duration) }}
|
{{ form_row(filterForm.duration) }}
|
||||||
|
|||||||
Reference in New Issue
Block a user