From 1097b8a50753094f23e381bebd9059ee4da818fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9o=20BOYER?= <t.boyer@si17.lan>
Date: Tue, 11 Feb 2025 10:41:38 +0100
Subject: [PATCH] [Formulaire] Ajout label gestion des droits et duplication

---
 CHANGELOG.md                                  |  3 +++
 .../Form/Type/ModeleAnalyseRightsType.php     |  4 ++--
 .../Admin/Form/Type/DuplicationType.php       |  4 ++--
 .../Form/Type/ModeleReferentielRightsType.php |  4 ++--
 templates/Admin/Duplication/new.html.twig     | 14 ++++++++------
 .../Aipd/Modele_analyse/rights.html.twig      | 19 ++++++++++++-------
 .../Maturity/Referentiel/rights.html.twig     | 19 ++++++++++++-------
 translations/messages.fr.yaml                 |  2 ++
 8 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index c72349d89..5732ebe05 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,8 +3,11 @@ CHANGELOG
 ## [2.4.9] - 2025-XX-XX
 ### Ajout
 - [Global] Ajout des champs absents dans les documents Word générés depuis la liste des différents modules.
+- [Formulaire] Ajout d'un label aux champs type et liste des structures dans la gestion des droits des modèles d'AIPD et dans les référentiels, ainsi que dans la duplication.
 - [Accessibilité] Ajout du plan d'actions 2025.
 - [Bilan] Ajout du score moyen de l'indice de maturité dans le bilan et dans le document Word de synthèse.
+- [Référentiels] Ajout du nom de l'élément modifié dans la gestion des droits des référentiels.
+- [AIPD] Ajout du nom de l'élément modifié dans la gestion des droits des modèles d'AIPD.
 - [AIPD] Ajout du modèle XML sur la vidéoprotection mis en oeuvre par les autorités publiques.
 ### Changement
 - [Global] Divers renommages et traductions.
diff --git a/src/Domain/AIPD/Form/Type/ModeleAnalyseRightsType.php b/src/Domain/AIPD/Form/Type/ModeleAnalyseRightsType.php
index 133c8296c..770856141 100644
--- a/src/Domain/AIPD/Form/Type/ModeleAnalyseRightsType.php
+++ b/src/Domain/AIPD/Form/Type/ModeleAnalyseRightsType.php
@@ -54,7 +54,7 @@ class ModeleAnalyseRightsType extends AbstractType
             ])
             ->add('authorizedCollectivityTypes', DictionaryType::class, [
                 'name'     => 'user_collectivity_type',
-                'label'    => false,
+                'label'    => 'global.label.organization_type',
                 'required' => false,
                 'multiple' => true,
                 'expanded' => false,
@@ -64,7 +64,7 @@ class ModeleAnalyseRightsType extends AbstractType
             ])
             ->add('authorizedCollectivities', EntityType::class, [
                 'class'         => Collectivity::class,
-                'label'         => false,
+                'label'         => 'global.label.organization_list',
                 'query_builder' => function (EntityRepository $er) {
                     return $er->createQueryBuilder('c')
                         ->orderBy('c.name', 'ASC');
diff --git a/src/Domain/Admin/Form/Type/DuplicationType.php b/src/Domain/Admin/Form/Type/DuplicationType.php
index 050412737..928abee0d 100644
--- a/src/Domain/Admin/Form/Type/DuplicationType.php
+++ b/src/Domain/Admin/Form/Type/DuplicationType.php
@@ -106,7 +106,7 @@ class DuplicationType extends AbstractType
             ])
             ->add('targetCollectivityTypes', DictionaryType::class, [
                 'name'     => 'user_collectivity_type',
-                'label'    => false,
+                'label'    => 'global.label.organization_type',
                 'required' => false,
                 'multiple' => true,
                 'expanded' => false,
@@ -116,7 +116,7 @@ class DuplicationType extends AbstractType
             ])
             ->add('targetCollectivities', EntityType::class, [
                 'class'         => UserModel\Collectivity::class,
-                'label'         => false,
+                'label'         => 'global.label.organization_list',
                 'query_builder' => function (EntityRepository $er) {
                     return $er->createQueryBuilder('c')
                         ->orderBy('c.name', 'ASC');
diff --git a/src/Domain/Maturity/Form/Type/ModeleReferentielRightsType.php b/src/Domain/Maturity/Form/Type/ModeleReferentielRightsType.php
index f0a00c0a7..9bf3e6bf5 100644
--- a/src/Domain/Maturity/Form/Type/ModeleReferentielRightsType.php
+++ b/src/Domain/Maturity/Form/Type/ModeleReferentielRightsType.php
@@ -54,7 +54,7 @@ class ModeleReferentielRightsType extends AbstractType
             ])
             ->add('authorizedCollectivityTypes', DictionaryType::class, [
                 'name'     => 'user_collectivity_type',
-                'label'    => false,
+                'label'    => 'global.label.organization_type',
                 'required' => false,
                 'multiple' => true,
                 'expanded' => false,
@@ -64,7 +64,7 @@ class ModeleReferentielRightsType extends AbstractType
             ])
             ->add('authorizedCollectivities', EntityType::class, [
                 'class'         => Collectivity::class,
-                'label'         => false,
+                'label'         => 'global.label.organization_list',
                 'query_builder' => function (EntityRepository $er) {
                     return $er->createQueryBuilder('c')
                         ->orderBy('c.name', 'ASC');
diff --git a/templates/Admin/Duplication/new.html.twig b/templates/Admin/Duplication/new.html.twig
index fca67fbc9..54f48704e 100644
--- a/templates/Admin/Duplication/new.html.twig
+++ b/templates/Admin/Duplication/new.html.twig
@@ -149,16 +149,18 @@
             let targetOption = $('#duplication_targetOption input[type=radio]:checked').val();
             let targetPerType = $('#duplication_targetCollectivityTypes');
             let targetPerCollectivity = $('#duplication_targetCollectivities');
+            let targetPerTypeDiv = targetPerType.closest('.form-group');  // Cible le div parent
+            let targetPerCollectivityDiv = targetPerCollectivity.closest('.form-group');  // Cible le div parent
 
             if (targetOption === '{{ constant('App\\Domain\\Admin\\Dictionary\\DuplicationTargetOptionDictionary::KEY_PER_TYPE') }}') {
-                targetPerType.show();
-                targetPerCollectivity.hide();
+                targetPerTypeDiv.show();  // Afficher le div
+                targetPerCollectivityDiv.hide();  // Cacher le div
             } else if (targetOption === '{{ constant('App\\Domain\\Admin\\Dictionary\\DuplicationTargetOptionDictionary::KEY_PER_COLLECTIVITY') }}') {
-                targetPerType.hide();
-                targetPerCollectivity.show();
+                targetPerTypeDiv.hide();  // Cacher le div
+                targetPerCollectivityDiv.show();  // Afficher le div
             } else {
-                targetPerType.hide();
-                targetPerCollectivity.hide();
+                targetPerTypeDiv.hide();  // Cacher le div
+                targetPerCollectivityDiv.hide();  // Cacher le div
             }
         }
 
diff --git a/templates/Aipd/Modele_analyse/rights.html.twig b/templates/Aipd/Modele_analyse/rights.html.twig
index cf9213a92..ee6988ac8 100644
--- a/templates/Aipd/Modele_analyse/rights.html.twig
+++ b/templates/Aipd/Modele_analyse/rights.html.twig
@@ -6,7 +6,10 @@
 {% block title %}{{ 'aipd.modele_analyse.title.rights'|trans }} - {{ parent() }}{% endblock %}
 
 {% block body_head %}
-    <h1>{{ 'aipd.modele_analyse.title.rights'|trans }}</h1>
+    <h1>
+        {{ 'aipd.modele_analyse.title.rights'|trans }}
+        <small>{{ form.vars.value.nom}}</small>
+    </h1>
 {% endblock %}
 
 {% block breadcrumb %}
@@ -73,16 +76,18 @@
             let targetOption = $('#modele_analyse_rights_optionRightSelection input[type=radio]:checked').val();
             let targetPerType = $('#modele_analyse_rights_authorizedCollectivityTypes');
             let targetPerCollectivity = $('#modele_analyse_rights_authorizedCollectivities');
+            let targetPerTypeDiv = targetPerType.closest('.form-group');  // Cible le div parent
+            let targetPerCollectivityDiv = targetPerCollectivity.closest('.form-group');  // Cible le div parent
 
             if (targetOption === '{{ constant('App\\Domain\\Admin\\Dictionary\\DuplicationTargetOptionDictionary::KEY_PER_TYPE') }}') {
-                targetPerType.show();
-                targetPerCollectivity.hide();
+                targetPerTypeDiv.show();  // Afficher le div
+                targetPerCollectivityDiv.hide();  // Cacher le div
             } else if (targetOption === '{{ constant('App\\Domain\\Admin\\Dictionary\\DuplicationTargetOptionDictionary::KEY_PER_COLLECTIVITY') }}') {
-                targetPerType.hide();
-                targetPerCollectivity.show();
+                targetPerTypeDiv.hide();  // Cacher le div
+                targetPerCollectivityDiv.show();  // Afficher le div
             } else {
-                targetPerType.hide();
-                targetPerCollectivity.hide();
+                targetPerTypeDiv.hide();  // Cacher le div
+                targetPerCollectivityDiv.hide();  // Cacher le div
             }
         }
 
diff --git a/templates/Maturity/Referentiel/rights.html.twig b/templates/Maturity/Referentiel/rights.html.twig
index 43a056958..f8ea984c4 100644
--- a/templates/Maturity/Referentiel/rights.html.twig
+++ b/templates/Maturity/Referentiel/rights.html.twig
@@ -6,7 +6,10 @@
 {% block title %}{{ 'maturity.referentiel.title.rights'|trans }} - {{ parent() }}{% endblock %}
 
 {% block body_head %}
-    <h1>{{ 'maturity.referentiel.title.rights'|trans }}</h1>
+    <h1>
+        {{ 'maturity.referentiel.title.rights'|trans }}
+        <small>{{ form.vars.value.name}}</small>
+    </h1>
 {% endblock %}
 
 {% block breadcrumb %}
@@ -76,16 +79,18 @@
             let targetOption = $('#modele_referentiel_rights_optionRightSelection input[type=radio]:checked').val();
             let targetPerType = $('#modele_referentiel_rights_authorizedCollectivityTypes');
             let targetPerCollectivity = $('#modele_referentiel_rights_authorizedCollectivities');
+            let targetPerTypeDiv = targetPerType.closest('.form-group');  // Cible le div parent
+            let targetPerCollectivityDiv = targetPerCollectivity.closest('.form-group');  // Cible le div parent
 
             if (targetOption === '{{ constant('App\\Domain\\Admin\\Dictionary\\DuplicationTargetOptionDictionary::KEY_PER_TYPE') }}') {
-                targetPerType.show();
-                targetPerCollectivity.hide();
+                targetPerTypeDiv.show();  // Afficher le div
+                targetPerCollectivityDiv.hide();  // Cacher le div
             } else if (targetOption === '{{ constant('App\\Domain\\Admin\\Dictionary\\DuplicationTargetOptionDictionary::KEY_PER_COLLECTIVITY') }}') {
-                targetPerType.hide();
-                targetPerCollectivity.show();
+                targetPerTypeDiv.hide();  // Cacher le div
+                targetPerCollectivityDiv.show();  // Afficher le div
             } else {
-                targetPerType.hide();
-                targetPerCollectivity.hide();
+                targetPerTypeDiv.hide();  // Cacher le div
+                targetPerCollectivityDiv.hide();  // Cacher le div
             }
         }
 
diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml
index 4c72327a7..7415ed5fb 100644
--- a/translations/messages.fr.yaml
+++ b/translations/messages.fr.yaml
@@ -39,6 +39,8 @@ global:
         archived: Archivé
         not_archived: Non archivé
         organization: Structure
+        organization_list: Liste des structures
+        organization_type: Type de structure
         service: Service
         created_at: Date de création
         created_by : Créé par
-- 
GitLab