From 456d29e60523420870fcc6ec22bc14ce08b32da2 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Nov 2024 15:28:11 +0100 Subject: [PATCH 01/14] Improve user experience for creation of document categories with select field for document class --- .../Form/DocumentCategoryType.php | 15 ++++++++++++++- .../views/DocumentCategory/index.html.twig | 4 ++-- .../translations/messages.fr.yml | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php index 6396314e2..7de35191b 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php @@ -17,15 +17,25 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Contracts\Translation\TranslatorInterface; class DocumentCategoryType extends AbstractType { + public function __construct(private readonly TranslatorInterface $translator) + { + } + public function buildForm(FormBuilderInterface $builder, array $options) { $bundles = [ 'chill-doc-store' => 'chill-doc-store', ]; + $documentClasses = [ + $this->translator->trans('Accompanying period document') => "Chill\DocStoreBundle\Entity\AccompanyingCourseDocument", + $this->translator->trans('Person document') => "Chill\DocStoreBundle\Entity\PersonDocument", + ]; + $builder ->add('bundleId', ChoiceType::class, [ 'choices' => $bundles, @@ -34,7 +44,10 @@ class DocumentCategoryType extends AbstractType ->add('idInsideBundle', null, [ 'disabled' => true, ]) - ->add('documentClass', null, [ + ->add('documentClass', ChoiceType::class, [ + 'choices' => $documentClasses, + 'expanded' => false, + 'required' => true, 'disabled' => false, ]) ->add('name', TranslatableStringFormType::class); diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/DocumentCategory/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/DocumentCategory/index.html.twig index ff20257a5..928e6ca27 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/DocumentCategory/index.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/DocumentCategory/index.html.twig @@ -8,7 +8,7 @@ - +{# #} @@ -18,7 +18,7 @@ {% for document_category in document_categories %} - +{# #} diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml index 4ba0307d7..fc5185b80 100644 --- a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml @@ -74,6 +74,8 @@ no records found: Create new category: Créer une nouvelle catégorie Back to the category list: Retour à la liste Create new DocumentCategory: Créer une nouvelle catégorie de document +Accompanying period document: Document de parcours d'accompagnement +Person document: Document de personne # WOPI EDIT online_edit_document: Éditer en ligne From 884b3684fefb61d968f27b82039f30a93a8a5479 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Nov 2024 15:28:52 +0100 Subject: [PATCH 02/14] Add a notnull constraint on property 'type' when creating an event status --- src/Bundle/ChillEventBundle/Entity/Status.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillEventBundle/Entity/Status.php b/src/Bundle/ChillEventBundle/Entity/Status.php index 38c07879c..89ec9e8b9 100644 --- a/src/Bundle/ChillEventBundle/Entity/Status.php +++ b/src/Bundle/ChillEventBundle/Entity/Status.php @@ -36,6 +36,7 @@ class Status private $name; #[ORM\ManyToOne(targetEntity: EventType::class, inversedBy: 'statuses')] + #[Assert\NotNull(message: 'An event status must be linked to an event type.')] private ?EventType $type = null; /** From 63c25780120dd47588734a818f11fb91249ce251 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Nov 2024 15:34:01 +0100 Subject: [PATCH 03/14] Improve layout of event admin section --- .../Resources/views/EventType/index.html.twig | 4 ++-- .../ChillEventBundle/Resources/views/Role/index.html.twig | 4 ++-- .../ChillEventBundle/Resources/views/Status/index.html.twig | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillEventBundle/Resources/views/EventType/index.html.twig b/src/Bundle/ChillEventBundle/Resources/views/EventType/index.html.twig index aeef9c19d..0a0154b3a 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/EventType/index.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/EventType/index.html.twig @@ -1,10 +1,10 @@ -{% extends "@ChillEvent/Admin/index.html.twig" %} +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} {% block admin_content -%}

{{ 'EventType list'|trans }}

-
{{ 'Creator bundle id' | trans }}{{ 'Creator bundle id' | trans }}{{ 'Internal id inside creator bundle' | trans }} {{ 'Document class' | trans }} {{ 'Name' | trans }}
{{ document_category.bundleId }}{{ document_category.bundleId }}{{ document_category.idInsideBundle }} {{ document_category.documentClass }} {{ document_category.name | localize_translatable_string}}
+
diff --git a/src/Bundle/ChillEventBundle/Resources/views/Role/index.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Role/index.html.twig index 6010576bc..e7e9afe1b 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Role/index.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Role/index.html.twig @@ -1,10 +1,10 @@ -{% extends "@ChillEvent/Admin/index.html.twig" %} +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} {% block admin_content -%}

{{ 'Role list'|trans }}

-
{{ 'Id'|trans }}
+
diff --git a/src/Bundle/ChillEventBundle/Resources/views/Status/index.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Status/index.html.twig index 114e2a1b1..64336b0d1 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Status/index.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Status/index.html.twig @@ -1,10 +1,10 @@ -{% extends "@ChillEvent/Admin/index.html.twig" %} +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} {% block admin_content -%}

{{ 'Status list'|trans }}

-
{{ 'Id'|trans }}
+
From 1ac9d32565367f05947b97d1b407162490dd75fb Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Nov 2024 15:43:22 +0100 Subject: [PATCH 04/14] Fix pipeline phpstan, rector, php-cs-fixer --- .../ChillDocStoreBundle/Form/DocumentCategoryType.php | 8 +++----- src/Bundle/ChillEventBundle/Entity/Status.php | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php index 7de35191b..e51d124e1 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php @@ -21,9 +21,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class DocumentCategoryType extends AbstractType { - public function __construct(private readonly TranslatorInterface $translator) - { - } + public function __construct(private readonly TranslatorInterface $translator) {} public function buildForm(FormBuilderInterface $builder, array $options) { @@ -32,8 +30,8 @@ class DocumentCategoryType extends AbstractType ]; $documentClasses = [ - $this->translator->trans('Accompanying period document') => "Chill\DocStoreBundle\Entity\AccompanyingCourseDocument", - $this->translator->trans('Person document') => "Chill\DocStoreBundle\Entity\PersonDocument", + $this->translator->trans('Accompanying period document') => \Chill\DocStoreBundle\Entity\AccompanyingCourseDocument::class, + $this->translator->trans('Person document') => \Chill\DocStoreBundle\Entity\PersonDocument::class, ]; $builder diff --git a/src/Bundle/ChillEventBundle/Entity/Status.php b/src/Bundle/ChillEventBundle/Entity/Status.php index 89ec9e8b9..a47011203 100644 --- a/src/Bundle/ChillEventBundle/Entity/Status.php +++ b/src/Bundle/ChillEventBundle/Entity/Status.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\EventBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * Class Status. From 4d53c8a2954b871ac3b347f4541871ffba9a11f9 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 6 Nov 2024 14:08:21 +0100 Subject: [PATCH 05/14] Add translations for gender form in admin --- src/Bundle/ChillMainBundle/Form/GenderType.php | 4 ++-- src/Bundle/ChillMainBundle/translations/messages.fr.yml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/GenderType.php b/src/Bundle/ChillMainBundle/Form/GenderType.php index 19a4af6cd..cecdace98 100644 --- a/src/Bundle/ChillMainBundle/Form/GenderType.php +++ b/src/Bundle/ChillMainBundle/Form/GenderType.php @@ -38,13 +38,13 @@ class GenderType extends AbstractType 'mapped' => true, 'choice_label' => fn (GenderIconEnum $enum) => '', 'choice_value' => fn (?GenderIconEnum $enum) => null !== $enum ? $enum->value : null, - 'label' => 'gender.admin.Select Gender Icon', + 'label' => 'gender.admin.Select gender icon', 'label_html' => true, ]) ->add('genderTranslation', EnumType::class, [ 'class' => GenderEnum::class, 'choice_label' => fn (GenderEnum $enum) => $enum->value, - 'label' => 'gender.admin.Select Gender Translation', + 'label' => 'gender.admin.Select gender translation', ]) ->add('active', ChoiceType::class, [ 'choices' => [ diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 02bdadb8a..b6a02dada 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -715,5 +715,7 @@ gender: genderTranslation: traduction grammaticale not defined: Non défini pick gender: Choisir une genre + Select gender translation: Traduction grammaticale + Select gender icon: Icône à utiliser From e2e24090abc014aeeb520148a6dcb2c90c530c32 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 7 Nov 2024 18:49:07 +0100 Subject: [PATCH 06/14] Allow the selection of multiple centers to create multiple groupcenters at once --- .../Controller/UserController.php | 17 +++++++++--- .../Form/Type/ComposedGroupCenterType.php | 26 +++++++------------ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 95c78300f..d65c3a404 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -64,10 +64,19 @@ class UserController extends CRUDController $form->handleRequest($request); if ($form->isValid()) { - $groupCenter = $this->getPersistedGroupCenter( - $form[self::FORM_GROUP_CENTER_COMPOSED]->getData() - ); - $user->addGroupCenter($groupCenter); + + $formData = $form[self::FORM_GROUP_CENTER_COMPOSED]->getData(); + $selectedCenters = $formData['center']; + + foreach ($selectedCenters as $center) { + $groupCenter = new GroupCenter(); + $groupCenter->setCenter($center); + $groupCenter->setPermissionsGroup($formData['permissionsgroup']); + + $user->addGroupCenter($groupCenter); + + $em->persist($groupCenter); + } if (0 === $this->validator->validate($user)->count()) { $em->flush(); diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php index 92a1e43e5..89a82d469 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php @@ -13,36 +13,30 @@ namespace Chill\MainBundle\Form\Type; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\PermissionsGroup; -use Doctrine\ORM\EntityRepository; +use Chill\MainBundle\Repository\CenterRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; class ComposedGroupCenterType extends AbstractType { + public function __construct(private readonly CenterRepository $centerRepository) {} + public function buildForm(FormBuilderInterface $builder, array $options) { + $centers = $this->centerRepository->findActive(); + $builder->add('permissionsgroup', EntityType::class, [ 'class' => PermissionsGroup::class, 'choice_label' => static fn (PermissionsGroup $group) => $group->getName(), - ])->add('center', EntityType::class, [ - 'class' => Center::class, - 'query_builder' => static function (EntityRepository $er) { - $qb = $er->createQueryBuilder('c'); - $qb->where($qb->expr()->eq('c.isActive', 'TRUE')) - ->orderBy('c.name', 'ASC'); - - return $qb; - }, + ])->add('center', ChoiceType::class, [ + 'choices' => $centers, + 'choice_label' => fn (Center $center) => $center->getName(), + 'multiple' => true, ]); } - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefault('data_class', \Chill\MainBundle\Entity\GroupCenter::class); - } - public function getBlockPrefix() { return 'composed_groupcenter'; From df30ca2c4f7bf22199688bb59f8fe034830489d8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Nov 2024 15:28:11 +0100 Subject: [PATCH 07/14] Improve user experience for creation of document categories with select field for document class --- .../Form/DocumentCategoryType.php | 15 ++++++++++++++- .../views/DocumentCategory/index.html.twig | 4 ++-- .../translations/messages.fr.yml | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php index 6396314e2..7de35191b 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php @@ -17,15 +17,25 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Contracts\Translation\TranslatorInterface; class DocumentCategoryType extends AbstractType { + public function __construct(private readonly TranslatorInterface $translator) + { + } + public function buildForm(FormBuilderInterface $builder, array $options) { $bundles = [ 'chill-doc-store' => 'chill-doc-store', ]; + $documentClasses = [ + $this->translator->trans('Accompanying period document') => "Chill\DocStoreBundle\Entity\AccompanyingCourseDocument", + $this->translator->trans('Person document') => "Chill\DocStoreBundle\Entity\PersonDocument", + ]; + $builder ->add('bundleId', ChoiceType::class, [ 'choices' => $bundles, @@ -34,7 +44,10 @@ class DocumentCategoryType extends AbstractType ->add('idInsideBundle', null, [ 'disabled' => true, ]) - ->add('documentClass', null, [ + ->add('documentClass', ChoiceType::class, [ + 'choices' => $documentClasses, + 'expanded' => false, + 'required' => true, 'disabled' => false, ]) ->add('name', TranslatableStringFormType::class); diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/DocumentCategory/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/DocumentCategory/index.html.twig index ff20257a5..928e6ca27 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/DocumentCategory/index.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/DocumentCategory/index.html.twig @@ -8,7 +8,7 @@
{{ 'Id'|trans }}
- +{# #} @@ -18,7 +18,7 @@ {% for document_category in document_categories %} - +{# #} diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml index 08adfbe06..05713ff28 100644 --- a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml @@ -74,6 +74,8 @@ no records found: Create new category: Créer une nouvelle catégorie Back to the category list: Retour à la liste Create new DocumentCategory: Créer une nouvelle catégorie de document +Accompanying period document: Document de parcours d'accompagnement +Person document: Document de personne # WOPI EDIT online_edit_document: Éditer en ligne From 3f381c207d0042b8ce64ff6730ef1532d2413e2d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Nov 2024 15:28:52 +0100 Subject: [PATCH 08/14] Add a notnull constraint on property 'type' when creating an event status --- src/Bundle/ChillEventBundle/Entity/Status.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillEventBundle/Entity/Status.php b/src/Bundle/ChillEventBundle/Entity/Status.php index 38c07879c..89ec9e8b9 100644 --- a/src/Bundle/ChillEventBundle/Entity/Status.php +++ b/src/Bundle/ChillEventBundle/Entity/Status.php @@ -36,6 +36,7 @@ class Status private $name; #[ORM\ManyToOne(targetEntity: EventType::class, inversedBy: 'statuses')] + #[Assert\NotNull(message: 'An event status must be linked to an event type.')] private ?EventType $type = null; /** From bc4c2c147188829d78b9bf542977a5dc44107d7c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Nov 2024 15:34:01 +0100 Subject: [PATCH 09/14] Improve layout of event admin section --- .../Resources/views/EventType/index.html.twig | 4 ++-- .../ChillEventBundle/Resources/views/Role/index.html.twig | 4 ++-- .../ChillEventBundle/Resources/views/Status/index.html.twig | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillEventBundle/Resources/views/EventType/index.html.twig b/src/Bundle/ChillEventBundle/Resources/views/EventType/index.html.twig index aeef9c19d..0a0154b3a 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/EventType/index.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/EventType/index.html.twig @@ -1,10 +1,10 @@ -{% extends "@ChillEvent/Admin/index.html.twig" %} +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} {% block admin_content -%}

{{ 'EventType list'|trans }}

-
{{ 'Creator bundle id' | trans }}{{ 'Creator bundle id' | trans }}{{ 'Internal id inside creator bundle' | trans }} {{ 'Document class' | trans }} {{ 'Name' | trans }}
{{ document_category.bundleId }}{{ document_category.bundleId }}{{ document_category.idInsideBundle }} {{ document_category.documentClass }} {{ document_category.name | localize_translatable_string}}
+
diff --git a/src/Bundle/ChillEventBundle/Resources/views/Role/index.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Role/index.html.twig index 6010576bc..e7e9afe1b 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Role/index.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Role/index.html.twig @@ -1,10 +1,10 @@ -{% extends "@ChillEvent/Admin/index.html.twig" %} +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} {% block admin_content -%}

{{ 'Role list'|trans }}

-
{{ 'Id'|trans }}
+
diff --git a/src/Bundle/ChillEventBundle/Resources/views/Status/index.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Status/index.html.twig index 114e2a1b1..64336b0d1 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Status/index.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Status/index.html.twig @@ -1,10 +1,10 @@ -{% extends "@ChillEvent/Admin/index.html.twig" %} +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} {% block admin_content -%}

{{ 'Status list'|trans }}

-
{{ 'Id'|trans }}
+
From ba3fe6af8cbbd91536301d3fa9411785a833ae76 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Nov 2024 15:43:22 +0100 Subject: [PATCH 10/14] Fix pipeline phpstan, rector, php-cs-fixer --- .../ChillDocStoreBundle/Form/DocumentCategoryType.php | 8 +++----- src/Bundle/ChillEventBundle/Entity/Status.php | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php index 7de35191b..e51d124e1 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php @@ -21,9 +21,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class DocumentCategoryType extends AbstractType { - public function __construct(private readonly TranslatorInterface $translator) - { - } + public function __construct(private readonly TranslatorInterface $translator) {} public function buildForm(FormBuilderInterface $builder, array $options) { @@ -32,8 +30,8 @@ class DocumentCategoryType extends AbstractType ]; $documentClasses = [ - $this->translator->trans('Accompanying period document') => "Chill\DocStoreBundle\Entity\AccompanyingCourseDocument", - $this->translator->trans('Person document') => "Chill\DocStoreBundle\Entity\PersonDocument", + $this->translator->trans('Accompanying period document') => \Chill\DocStoreBundle\Entity\AccompanyingCourseDocument::class, + $this->translator->trans('Person document') => \Chill\DocStoreBundle\Entity\PersonDocument::class, ]; $builder diff --git a/src/Bundle/ChillEventBundle/Entity/Status.php b/src/Bundle/ChillEventBundle/Entity/Status.php index 89ec9e8b9..a47011203 100644 --- a/src/Bundle/ChillEventBundle/Entity/Status.php +++ b/src/Bundle/ChillEventBundle/Entity/Status.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\EventBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * Class Status. From 63fc4f10897a02b4c99726d00aaf8e0ed0d80c0f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 6 Nov 2024 14:08:21 +0100 Subject: [PATCH 11/14] Add translations for gender form in admin --- src/Bundle/ChillMainBundle/Form/GenderType.php | 4 ++-- src/Bundle/ChillMainBundle/translations/messages.fr.yml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/GenderType.php b/src/Bundle/ChillMainBundle/Form/GenderType.php index 19a4af6cd..cecdace98 100644 --- a/src/Bundle/ChillMainBundle/Form/GenderType.php +++ b/src/Bundle/ChillMainBundle/Form/GenderType.php @@ -38,13 +38,13 @@ class GenderType extends AbstractType 'mapped' => true, 'choice_label' => fn (GenderIconEnum $enum) => '', 'choice_value' => fn (?GenderIconEnum $enum) => null !== $enum ? $enum->value : null, - 'label' => 'gender.admin.Select Gender Icon', + 'label' => 'gender.admin.Select gender icon', 'label_html' => true, ]) ->add('genderTranslation', EnumType::class, [ 'class' => GenderEnum::class, 'choice_label' => fn (GenderEnum $enum) => $enum->value, - 'label' => 'gender.admin.Select Gender Translation', + 'label' => 'gender.admin.Select gender translation', ]) ->add('active', ChoiceType::class, [ 'choices' => [ diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index eeecfccb7..d2a760d53 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -792,5 +792,7 @@ gender: genderTranslation: traduction grammaticale not defined: Non défini pick gender: Choisir une genre + Select gender translation: Traduction grammaticale + Select gender icon: Icône à utiliser From 0f1604817bfadedcf0cc8aeb34880360a314e378 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 7 Nov 2024 18:49:07 +0100 Subject: [PATCH 12/14] Allow the selection of multiple centers to create multiple groupcenters at once --- .../Controller/UserController.php | 17 +++++++++--- .../Form/Type/ComposedGroupCenterType.php | 26 +++++++------------ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 95c78300f..d65c3a404 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -64,10 +64,19 @@ class UserController extends CRUDController $form->handleRequest($request); if ($form->isValid()) { - $groupCenter = $this->getPersistedGroupCenter( - $form[self::FORM_GROUP_CENTER_COMPOSED]->getData() - ); - $user->addGroupCenter($groupCenter); + + $formData = $form[self::FORM_GROUP_CENTER_COMPOSED]->getData(); + $selectedCenters = $formData['center']; + + foreach ($selectedCenters as $center) { + $groupCenter = new GroupCenter(); + $groupCenter->setCenter($center); + $groupCenter->setPermissionsGroup($formData['permissionsgroup']); + + $user->addGroupCenter($groupCenter); + + $em->persist($groupCenter); + } if (0 === $this->validator->validate($user)->count()) { $em->flush(); diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php index 92a1e43e5..89a82d469 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php @@ -13,36 +13,30 @@ namespace Chill\MainBundle\Form\Type; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\PermissionsGroup; -use Doctrine\ORM\EntityRepository; +use Chill\MainBundle\Repository\CenterRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; class ComposedGroupCenterType extends AbstractType { + public function __construct(private readonly CenterRepository $centerRepository) {} + public function buildForm(FormBuilderInterface $builder, array $options) { + $centers = $this->centerRepository->findActive(); + $builder->add('permissionsgroup', EntityType::class, [ 'class' => PermissionsGroup::class, 'choice_label' => static fn (PermissionsGroup $group) => $group->getName(), - ])->add('center', EntityType::class, [ - 'class' => Center::class, - 'query_builder' => static function (EntityRepository $er) { - $qb = $er->createQueryBuilder('c'); - $qb->where($qb->expr()->eq('c.isActive', 'TRUE')) - ->orderBy('c.name', 'ASC'); - - return $qb; - }, + ])->add('center', ChoiceType::class, [ + 'choices' => $centers, + 'choice_label' => fn (Center $center) => $center->getName(), + 'multiple' => true, ]); } - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefault('data_class', \Chill\MainBundle\Entity\GroupCenter::class); - } - public function getBlockPrefix() { return 'composed_groupcenter'; From b327f65ef81245873d5ed28a25ff39f809fdb040 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 20 Nov 2024 12:43:50 +0100 Subject: [PATCH 13/14] Fix the logic of adding a permission group to avoid duplicates being made --- .../Controller/UserController.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index d65c3a404..66c084e11 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -12,7 +12,9 @@ declare(strict_types=1); namespace Chill\MainBundle\Controller; use Chill\MainBundle\CRUD\Controller\CRUDController; +use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\GroupCenter; +use Chill\MainBundle\Entity\PermissionsGroup; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\Type\ComposedGroupCenterType; use Chill\MainBundle\Form\UserCurrentLocationType; @@ -69,13 +71,8 @@ class UserController extends CRUDController $selectedCenters = $formData['center']; foreach ($selectedCenters as $center) { - $groupCenter = new GroupCenter(); - $groupCenter->setCenter($center); - $groupCenter->setPermissionsGroup($formData['permissionsgroup']); - + $groupCenter = $this->getPersistedGroupCenter($center, $formData['permissionsgroup']); $user->addGroupCenter($groupCenter); - - $em->persist($groupCenter); } if (0 === $this->validator->validate($user)->count()) { @@ -428,17 +425,21 @@ class UserController extends CRUDController } } - private function getPersistedGroupCenter(GroupCenter $groupCenter) + private function getPersistedGroupCenter(Center $center, PermissionsGroup $permissionsGroup) { $em = $this->managerRegistry->getManager(); $groupCenterManaged = $em->getRepository(GroupCenter::class) ->findOneBy([ - 'center' => $groupCenter->getCenter(), - 'permissionsGroup' => $groupCenter->getPermissionsGroup(), + 'center' => $center, + 'permissionsGroup' => $permissionsGroup, ]); if (!$groupCenterManaged) { + $groupCenter = new GroupCenter(); + $groupCenter->setCenter($center); + $groupCenter->setPermissionsGroup($permissionsGroup); + $em->persist($groupCenter); return $groupCenter; From 6536662abaddd53275da6ef7fcc9d743d3b6407f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 20 Nov 2024 14:07:07 +0100 Subject: [PATCH 14/14] add changie for admin improvements --- .changes/unreleased/Feature-20241120-140556.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Feature-20241120-140556.yaml diff --git a/.changes/unreleased/Feature-20241120-140556.yaml b/.changes/unreleased/Feature-20241120-140556.yaml new file mode 100644 index 000000000..ab0c8b9cf --- /dev/null +++ b/.changes/unreleased/Feature-20241120-140556.yaml @@ -0,0 +1,7 @@ +kind: Feature +body: |- + Admin: improve document type admin form with a select field for related class. + Admin: Allow administrator to assign multiple group centers in one go to a user. +time: 2024-11-20T14:05:56.69669451+01:00 +custom: + Issue: "314"
{{ 'Id'|trans }}