feat: pending roles from crm to be confirmed by superadmins
This commit is contained in:
1 parent
681734533f
commit
b01c2e84c7
26 files changed
+907
-150
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Config\HouseCatalog;
|
||||
use App\Entity\Assignment;
|
||||
use App\Entity\JobProfile;
|
||||
use App\Model\ApplicationFilterDto;
|
||||
@@ -17,15 +18,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ApplicationFilterType extends AbstractType
|
||||
{
|
||||
private array $hotelChoices = [];
|
||||
|
||||
public function __construct(private readonly Security $security, private readonly array $destinations)
|
||||
public function __construct(private readonly Security $security, private readonly HouseCatalog $houseCatalog)
|
||||
{
|
||||
$destinations = $this->destinations;
|
||||
sort($destinations);
|
||||
foreach ($destinations as $item) {
|
||||
$this->hotelChoices[$item] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
@@ -126,7 +120,7 @@ class ApplicationFilterType extends AbstractType
|
||||
'label' => 'Haus/Destination',
|
||||
'required' => false,
|
||||
'empty_label' => 'nicht filtern',
|
||||
'choices' => $this->hotelChoices,
|
||||
'choices' => $this->houseCatalog->getNameChoices(),
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Config\HouseCatalog;
|
||||
use App\Entity\Assignment;
|
||||
use App\Entity\JobProfile;
|
||||
use App\Model\AssignmentFilterDto;
|
||||
@@ -17,15 +18,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class AssignmentFilterType extends AbstractType
|
||||
{
|
||||
private array $hotelChoices = [];
|
||||
|
||||
public function __construct(private readonly Security $security, private readonly array $destinations)
|
||||
public function __construct(private readonly Security $security, private readonly HouseCatalog $houseCatalog)
|
||||
{
|
||||
$destinations = $this->destinations;
|
||||
sort($destinations);
|
||||
foreach ($destinations as $item) {
|
||||
$this->hotelChoices[$item] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
@@ -130,7 +124,7 @@ class AssignmentFilterType extends AbstractType
|
||||
'label' => 'Haus/Destination',
|
||||
'required' => false,
|
||||
'empty_label' => 'nicht filtern',
|
||||
'choices' => $this->hotelChoices,
|
||||
'choices' => $this->houseCatalog->getNameChoices(),
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Config\HouseCatalog;
|
||||
use App\Model\DestinationFilterDto;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
@@ -12,15 +13,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class DestinationFilterType extends AbstractType
|
||||
{
|
||||
private array $hotelChoices = [];
|
||||
|
||||
public function __construct(private readonly array $destinations)
|
||||
public function __construct(private readonly HouseCatalog $houseCatalog)
|
||||
{
|
||||
$destinations = $this->destinations;
|
||||
sort($destinations);
|
||||
foreach ($destinations as $item) {
|
||||
$this->hotelChoices[$item] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
@@ -30,7 +24,7 @@ class DestinationFilterType extends AbstractType
|
||||
'label' => 'Haus/Destination',
|
||||
'required' => false,
|
||||
'empty_label' => 'nicht filtern',
|
||||
'choices' => $this->hotelChoices,
|
||||
'choices' => $this->houseCatalog->getNameChoices(),
|
||||
])
|
||||
->add('apply', SubmitType::class, [
|
||||
'label' => 'filtern',
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Config\HouseCatalog;
|
||||
use App\Entity\JobProfile;
|
||||
use App\Entity\Teamer;
|
||||
use App\Entity\Upload;
|
||||
@@ -14,15 +15,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class DocumentFilterType extends AbstractType
|
||||
{
|
||||
private array $hotelChoices = [];
|
||||
|
||||
public function __construct(private readonly array $destinations)
|
||||
public function __construct(private readonly HouseCatalog $houseCatalog)
|
||||
{
|
||||
$destinations = $this->destinations;
|
||||
sort($destinations);
|
||||
foreach ($destinations as $item) {
|
||||
$this->hotelChoices[$item] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
@@ -56,7 +50,7 @@ class DocumentFilterType extends AbstractType
|
||||
'label' => 'Haus/Destination',
|
||||
'required' => false,
|
||||
'empty_label' => 'nicht filtern',
|
||||
'choices' => $this->hotelChoices,
|
||||
'choices' => $this->houseCatalog->getNameChoices(),
|
||||
])
|
||||
->add('dateFrom', DatepickerType::class, [
|
||||
'label' => 'Einsatzzeitraum von',
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Config\HouseCatalog;
|
||||
use App\Model\TimelineFilterDto;
|
||||
use App\Service\Assignment\TimelineService;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
@@ -15,7 +16,7 @@ class TimelineFilterType extends AbstractType
|
||||
public function __construct(
|
||||
private readonly TimelineService $timelineService,
|
||||
private readonly Security $security,
|
||||
private readonly array $destinations,
|
||||
private readonly HouseCatalog $houseCatalog,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -53,19 +54,12 @@ class TimelineFilterType extends AbstractType
|
||||
;
|
||||
|
||||
if (false === $this->security->isGranted('ROLE_HOUSE_MANAGER')) {
|
||||
$destinations = $this->destinations;
|
||||
$hotelChoices = [];
|
||||
sort($destinations);
|
||||
foreach ($destinations as $item) {
|
||||
$hotelChoices[$item] = $item;
|
||||
}
|
||||
|
||||
$builder
|
||||
->add('hotels', MultiselectType::class, [
|
||||
'label' => 'Haus/Destination',
|
||||
'required' => false,
|
||||
'empty_label' => 'nicht filtern',
|
||||
'choices' => $hotelChoices,
|
||||
'choices' => $this->houseCatalog->getNameChoices(),
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Config\HouseCatalog;
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class UserType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly HouseCatalog $houseCatalog)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('roles', MultiselectType::class, [
|
||||
'label' => 'Rollen',
|
||||
'required' => false,
|
||||
'property_path' => 'assignedRoles',
|
||||
'choices' => array_flip(User::ROLES),
|
||||
'empty_label' => 'keine Rolle',
|
||||
])
|
||||
->add('superAdmin', CheckboxType::class, [
|
||||
'label' => 'Superadmin',
|
||||
'required' => false,
|
||||
'help' => 'Setzt die Rolle Admin voraus.',
|
||||
])
|
||||
;
|
||||
|
||||
// hotel codes already assigned to the user may predate the catalog, so they are
|
||||
// added as choices to keep them selectable instead of failing
|
||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {
|
||||
$user = $event->getData();
|
||||
|
||||
$choices = $this->houseCatalog->getCodeChoices();
|
||||
foreach ($user instanceof User ? $user->getHotelCodes() : [] as $code) {
|
||||
if (false === in_array($code, $choices, true)) {
|
||||
$choices[$code] = $code;
|
||||
}
|
||||
}
|
||||
|
||||
$event->getForm()->add('hotelCodes', MultiselectType::class, [
|
||||
'label' => 'Häuser',
|
||||
'required' => false,
|
||||
'choices' => $choices,
|
||||
'empty_label' => 'keine Häuser',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user