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"
diff --git a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php
index 6396314e2..e51d124e1 100644
--- a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php
+++ b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php
@@ -17,15 +17,23 @@ 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::class,
+ $this->translator->trans('Person document') => \Chill\DocStoreBundle\Entity\PersonDocument::class,
+ ];
+
$builder
->add('bundleId', ChoiceType::class, [
'choices' => $bundles,
@@ -34,7 +42,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 @@
- {{ 'Creator bundle id' | trans }} |
+{# {{ 'Creator bundle id' | trans }} | #}
{{ 'Internal id inside creator bundle' | trans }} |
{{ 'Document class' | trans }} |
{{ 'Name' | trans }} |
@@ -18,7 +18,7 @@
{% for document_category in document_categories %}
- {{ document_category.bundleId }} |
+{# {{ document_category.bundleId }} | #}
{{ document_category.idInsideBundle }} |
{{ document_category.documentClass }} |
{{ document_category.name | localize_translatable_string}} |
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
diff --git a/src/Bundle/ChillEventBundle/Entity/Status.php b/src/Bundle/ChillEventBundle/Entity/Status.php
index 38c07879c..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.
@@ -36,6 +37,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;
/**
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 }}
-
+
{{ 'Id'|trans }} |
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 }} |
diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php
index 95c78300f..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;
@@ -64,10 +66,14 @@ 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 = $this->getPersistedGroupCenter($center, $formData['permissionsgroup']);
+ $user->addGroupCenter($groupCenter);
+ }
if (0 === $this->validator->validate($user)->count()) {
$em->flush();
@@ -419,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;
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/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';
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