Feat: Add assignment filter for admins
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Destination;
|
||||
use App\Entity\JobProfile;
|
||||
use App\Model\AssignmentFilterDto;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class AssignmentFilterType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('dateFrom', DatepickerType::class, [
|
||||
'label' => false,
|
||||
'min_date' => $options['min_date'],
|
||||
'max_date' => $options['max_date'],
|
||||
'attr' => [
|
||||
'placeholder' => 'von',
|
||||
],
|
||||
])
|
||||
->add('dateTo', DatepickerType::class, [
|
||||
'label' => false,
|
||||
'min_date' => $options['min_date'],
|
||||
'max_date' => $options['max_date'],
|
||||
'attr' => [
|
||||
'placeholder' => 'bis',
|
||||
],
|
||||
])
|
||||
->add('duration', ChoiceType::class, [
|
||||
'label' => false,
|
||||
'placeholder' => 'Einsatzdauer',
|
||||
'choices' => [
|
||||
'Wochenende (2-4 Tage)' => AssignmentFilterDto::DURATION_WEEKEND,
|
||||
'Midweek (5-6 Tage)' => AssignmentFilterDto::DURATION_MID_WEEK,
|
||||
'Ganze Woche (7 Tage)' => AssignmentFilterDto::DURATION_FULL_WEEK,
|
||||
'Mehr als einen Woche' => AssignmentFilterDto::DURATION_MORE,
|
||||
],
|
||||
])
|
||||
->add('apply', SubmitType::class, [
|
||||
'label' => 'anwenden',
|
||||
])
|
||||
->add('reset', SubmitType::class, [
|
||||
'label' => 'reset',
|
||||
])
|
||||
;
|
||||
|
||||
if (0 < count($options['job_profiles'])) {
|
||||
$builder
|
||||
->add('jobProfile', EntityType::class, [
|
||||
'label' => false,
|
||||
'placeholder' => 'Job-Profil',
|
||||
'class' => JobProfile::class,
|
||||
'choice_label' => 'name',
|
||||
'choices' => $options['job_profiles'],
|
||||
])
|
||||
;
|
||||
}
|
||||
if (0 < count($options['destinations'])) {
|
||||
$builder
|
||||
->add('destination', EntityType::class, [
|
||||
'label' => false,
|
||||
'placeholder' => 'Destination',
|
||||
'class' => Destination::class,
|
||||
'choice_label' => function (Destination $destination) {
|
||||
return $destination->getProduct();
|
||||
},
|
||||
'choices' => $options['destinations'],
|
||||
])
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver
|
||||
->setDefaults([
|
||||
'data_class' => AssignmentFilterDto::class,
|
||||
'min_date' => null,
|
||||
'max_date' => null,
|
||||
'job_profiles' => [],
|
||||
'destinations' => [],
|
||||
])
|
||||
->setAllowedTypes('min_date', [\DateTimeImmutable::class, 'null'])
|
||||
->setAllowedTypes('max_date', [\DateTimeImmutable::class, 'null'])
|
||||
;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user