From 2cc881391b24a1210178d5aa9babde16681166b1 Mon Sep 17 00:00:00 2001 From: Mathieu Santostefano Date: Wed, 20 Apr 2022 16:23:47 +0200 Subject: [PATCH] fix: limit conferences selects to future conferences --- config/packages/easy_admin/participation.yaml | 2 +- config/packages/easy_admin/talk.yaml | 2 +- ...ticipationConferencesType.php => FutureConferencesType.php} | 2 +- src/Form/EasyAdmin/TalkSubmitType.php | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) rename src/Form/EasyAdmin/{ParticipationConferencesType.php => FutureConferencesType.php} (95%) diff --git a/config/packages/easy_admin/participation.yaml b/config/packages/easy_admin/participation.yaml index a586ce23..40b8531f 100644 --- a/config/packages/easy_admin/participation.yaml +++ b/config/packages/easy_admin/participation.yaml @@ -21,7 +21,7 @@ easy_admin: item_permission: ['ROLE_PARTICIPATION_MANAGEMENT'] fields: - { type: 'group', columns: 6, icon: 'id-badge', label: 'Participation' } - - { property: 'conference', type: 'App\Form\EasyAdmin\ParticipationConferencesType', type_options: { attr: { data-widget: 'select2' } } } + - { property: 'conference', type: 'App\Form\EasyAdmin\FutureConferencesType', type_options: { attr: { data-widget: 'select2' } } } - { property: 'participant' } - { property: 'asSpeaker' } - property: 'transportStatus' diff --git a/config/packages/easy_admin/talk.yaml b/config/packages/easy_admin/talk.yaml index ae64922c..f60770c7 100644 --- a/config/packages/easy_admin/talk.yaml +++ b/config/packages/easy_admin/talk.yaml @@ -31,6 +31,6 @@ easy_admin: fields: <<: *talkFields 4: { type: 'group', columns: 6, icon: 'send', label: 'Publication' } - 5: { property: 'conferences', type: 'easyadmin_autocomplete', type_options: { mapped: false, class: App\Entity\Conference, multiple: true } } + 5: { property: 'conference', type: 'App\Form\EasyAdmin\FutureConferencesType', type_options: { mapped: false, class: App\Entity\Conference, multiple: true, attr: { data-widget: 'select2' } } } 6: { property: authors, type: App\Form\EasyAdmin\TalkUserType, type_options: { mapped: false, required: true } } diff --git a/src/Form/EasyAdmin/ParticipationConferencesType.php b/src/Form/EasyAdmin/FutureConferencesType.php similarity index 95% rename from src/Form/EasyAdmin/ParticipationConferencesType.php rename to src/Form/EasyAdmin/FutureConferencesType.php index 66028e95..e05e9703 100644 --- a/src/Form/EasyAdmin/ParticipationConferencesType.php +++ b/src/Form/EasyAdmin/FutureConferencesType.php @@ -18,7 +18,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -class ParticipationConferencesType extends AbstractType +class FutureConferencesType extends AbstractType { public function __construct( private ConferenceRepository $conferenceRepository, diff --git a/src/Form/EasyAdmin/TalkSubmitType.php b/src/Form/EasyAdmin/TalkSubmitType.php index c5282302..fe31f441 100644 --- a/src/Form/EasyAdmin/TalkSubmitType.php +++ b/src/Form/EasyAdmin/TalkSubmitType.php @@ -15,6 +15,7 @@ use App\Entity\Submit; use App\Entity\Talk; use App\Entity\User; +use App\Repository\ConferenceRepository; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\EasyAdminAutocompleteType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -29,6 +30,7 @@ class TalkSubmitType extends AbstractType { public function __construct( private RequestStack $requestStack, + private ConferenceRepository $conferenceRepository, ) { } @@ -40,6 +42,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]) ->add('conference', EasyAdminAutocompleteType::class, [ 'class' => Conference::class, + 'query_builder' => $this->conferenceRepository->getFutureConferencesQueryBuilder(), ]) ->add('status', ChoiceType::class, [ 'choices' => array_flip(Submit::STATUS_EMOJIS),