{{ entity.id }} |
{{ entity.title|localize_translatable_string }} |
+
+ {% if entity.desactivationDate is not null %}
+ {{ entity.desactivationDate|date('Y-m-d') }}
+ {% endif %}
+ |
-
diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
index 9e3409dfc..0ec2d7275 100644
--- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
@@ -465,6 +465,7 @@ closing_motive:
any parent: Aucun parent
new child: Nouvel enfant
+Person configuration: Configuration du module "Personnes"
Configuration of person bundle: Configuration du module "Personnes"
person_admin:
accompanying_period: Parcours d'accompagnement
@@ -482,7 +483,7 @@ person_admin:
person_resource_kind: Type de personne ressource
social_issue: Problématiques sociales
social_action: Actions d'accompagnement
- social_goal: Buts
+ social_goal: Objectifs
social_result: Résultats
social_evaluation: Évaluations
social_work: Accompagnement social
@@ -528,7 +529,9 @@ accompanying_course:
comment is unpinned: Le commentaire est désépinglé
show: Montrer
hide: Masquer
-closed periods: parcours clôturer
+closed periods: parcours clôturés
+Accompanying course configuration: Gestion des parcours d'accompagnement
+Social work configuration: Gestion des actions d'accompagnement social
# Accompanying Course comments
Accompanying Course Comment: Commentaire
@@ -565,6 +568,7 @@ Budget: Budget
The composition has been successfully removed.: La composition a été supprimée.
edit address valid from: Modifier la date du déménagement
Edit household address valid from: Modifier la date du déménagement
+Household configuration: Gestion des ménages
# accompanying course work
From fa458c54ecd2981586bd2e953e2566b463c8777c Mon Sep 17 00:00:00 2001
From: nobohan
Date: Wed, 11 May 2022 11:50:17 +0200
Subject: [PATCH 42/49] admin: adapt social work form type and templates
---
.../Form/SocialWork/GoalType.php | 10 ++++++
.../Form/SocialWork/SocialActionType.php | 31 +++++++++++++++++++
.../views/SocialWork/Goal/index.html.twig | 6 ++++
.../SocialWork/SocialAction/edit.html.twig | 2 +-
.../SocialWork/SocialAction/index.html.twig | 24 ++++++++++++++
.../translations/messages.fr.yml | 1 +
6 files changed, 73 insertions(+), 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php
index f1005d696..45a43897d 100644
--- a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php
+++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php
@@ -15,6 +15,7 @@ use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\SocialWork\Goal;
+use Chill\PersonBundle\Entity\SocialWork\Result;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
@@ -52,6 +53,15 @@ class GoalType extends AbstractType
},
])
+ ->add('results', EntityType::class, [
+ 'class' => Result::class,
+ 'required' => false,
+ 'multiple' => true,
+ 'choice_label' => function (Result $r) {
+ return $this->translatableStringHelper->localize($r->getTitle());
+ },
+ ])
+
->add('desactivationDate', ChillDateType::class, [
'required' => false,
'label' => 'goal.desactivationDate',
diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php
index c476a899f..f6d93bc42 100644
--- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php
+++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php
@@ -15,6 +15,9 @@ use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\DateIntervalType;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
+use Chill\PersonBundle\Entity\SocialWork\Evaluation;
+use Chill\PersonBundle\Entity\SocialWork\Goal;
+use Chill\PersonBundle\Entity\SocialWork\Result;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -57,6 +60,34 @@ class SocialActionType extends AbstractType
return $this->translatableStringHelper->localize($issue->getTitle());
},
])
+
+ ->add('results', EntityType::class, [
+ 'class' => Result::class,
+ 'required' => false,
+ 'multiple' => true,
+ 'choice_label' => function (Result $r) {
+ return $this->translatableStringHelper->localize($r->getTitle());
+ },
+ ])
+
+ ->add('goals', EntityType::class, [
+ 'class' => Goal::class,
+ 'required' => false,
+ 'multiple' => true,
+ 'choice_label' => function (Goal $g) {
+ return $this->translatableStringHelper->localize($g->getTitle());
+ },
+ ])
+
+ ->add('evaluations', EntityType::class, [
+ 'class' => Evaluation::class,
+ 'required' => false,
+ 'multiple' => true,
+ 'choice_label' => function (Evaluation $e) {
+ return $this->translatableStringHelper->localize($e->getTitle());
+ },
+ ])
+
->add('defaultNotificationDelay', DateIntervalType::class, [
'label' => 'socialAction.defaultNotificationDelay',
'required' => false,
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Goal/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Goal/index.html.twig
index 31db795be..20f944595 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Goal/index.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Goal/index.html.twig
@@ -6,6 +6,7 @@
{{ 'Id'|trans }} |
{{ 'Title'|trans }} |
{{ 'Social actions'|trans }} |
+ {{ 'goal.results'|trans }} |
{{ 'goal.desactivationDate'|trans }} |
|
{% endblock %}
@@ -21,6 +22,11 @@
{% endfor %}
|
+ {% for sa in entity.results %}
+ {{ sa.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
+ {% endfor %}
+ |
+
{% if entity.desactivationDate is not null %}
{{ entity.desactivationDate|date('Y-m-d') }}
{% endif %}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/edit.html.twig
index ffad69128..49d6635df 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/edit.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/edit.html.twig
@@ -9,7 +9,7 @@
{% block crud_content_form_rows %}
{% for f in form %}
- {% if f.vars.name == 'parent' %}
+ {% if f.vars.name == 'parent' or f.vars.name == 'issue' %}
{{ form_row(f, { 'attr':{'disabled':'disabled'}}) }}
{% else %}
{{ form_row(f) }}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig
index acfce6ee6..e2e21fca8 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig
@@ -6,6 +6,10 @@
| {{ 'Id'|trans }} |
{{ 'Title'|trans }} |
{{ 'Parent'|trans }} |
+ {{ 'Social issue'|trans }} |
+ {{ 'Results'|trans }} |
+ {{ 'Goals'|trans }} |
+ {{ 'Evaluations'|trans }} |
{{ 'goal.desactivationDate'|trans }} |
{{ 'socialAction.defaultNotificationDelay'|trans }} |
|
@@ -22,6 +26,26 @@
{% endif %}
+ {% for e in entity.issue %}
+ {{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
+ {% endfor %}
+ |
+
+ {% for e in entity.results %}
+ {{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
+ {% endfor %}
+ |
+
+ {% for e in entity.goals %}
+ {{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
+ {% endfor %}
+ |
+
+ {% for e in entity.evaluations %}
+ {{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
+ {% endfor %}
+ |
+
{% if entity.desactivationDate is not null %}
{{ entity.desactivationDate|date('Y-m-d') }}
{% endif %}
diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
index 0ec2d7275..e95960248 100644
--- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
@@ -443,6 +443,7 @@ evaluation:
goal:
desactivationDate: Date de désactivation
+ results: Résultats
socialAction:
defaultNotificationDelay: Délai de notification par défaut
From f44b9ca05bc24c6aa0487e93b6ab97cc42c18d5b Mon Sep 17 00:00:00 2001
From: nobohan
Date: Wed, 11 May 2022 12:03:38 +0200
Subject: [PATCH 43/49] admin: fix error when creating document category
---
src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php b/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php
index 55850b157..884447599 100644
--- a/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php
+++ b/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php
@@ -100,4 +100,11 @@ class DocumentCategory
return $this;
}
+
+ public function setBundleId($id): self
+ {
+ $this->bundleId = $id;
+
+ return $this;
+ }
}
From 05088b596430e829977f8fa377744993816667d4 Mon Sep 17 00:00:00 2001
From: nobohan
Date: Wed, 11 May 2022 12:14:46 +0200
Subject: [PATCH 44/49] upd CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4afdffe7a..e43212b4c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ and this project adheres to
## Unreleased
+* [admin] refactorisation of the admin section: reorganisation of the menu, translations, form types, new entities (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/592)
* [admin] add admin section for languages and countries (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/596)
* [activity] activity admin: translations + remove label field for comment on admin activity type (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/587)
* [main] admin user_job: improvements (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/588)
From a9df9f4880186dc7d03c07da14cfce111d1452fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Fri, 13 May 2022 15:36:20 +0200
Subject: [PATCH 45/49] add ordering on some social work + minor improves
---
.../SocialWork/SocialActionController.php | 2 +-
.../SocialWork/SocialIssueController.php | 2 +-
.../Form/SocialWork/SocialActionType.php | 9 +++-
.../Form/SocialWork/SocialIssueType.php | 5 ++
.../AdminAccompanyingCourseMenuBuilder.php | 2 +-
.../SocialWork/SocialAction/index.html.twig | 48 ++-----------------
.../SocialWork/SocialIssue/index.html.twig | 8 ++--
.../translations/messages.fr.yml | 2 +-
8 files changed, 24 insertions(+), 54 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialActionController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialActionController.php
index ccb657da7..47cc246bd 100644
--- a/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialActionController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialActionController.php
@@ -19,7 +19,7 @@ class SocialActionController extends CRUDController
{
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
{
- $query->addOrderBy('e.id', 'ASC');
+ $query->addOrderBy('e.ordering', 'ASC');
return parent::orderQuery($action, $query, $request, $paginator);
}
diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php
index 5531d1e4b..57dd38e80 100644
--- a/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php
@@ -19,7 +19,7 @@ class SocialIssueController extends CRUDController
{
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
{
- $query->addOrderBy('e.id', 'ASC');
+ $query->addOrderBy('e.ordering', 'ASC');
return parent::orderQuery($action, $query, $request, $paginator);
}
diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php
index f6d93bc42..77c94fa9d 100644
--- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php
+++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php
@@ -22,6 +22,7 @@ use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -60,11 +61,15 @@ class SocialActionType extends AbstractType
return $this->translatableStringHelper->localize($issue->getTitle());
},
])
-
+ ->add('ordering', NumberType::class, [
+ 'required' => true,
+ 'scale' => 6,
+ ])
->add('results', EntityType::class, [
'class' => Result::class,
'required' => false,
'multiple' => true,
+ 'attr' => ['class' => 'select2'],
'choice_label' => function (Result $r) {
return $this->translatableStringHelper->localize($r->getTitle());
},
@@ -74,6 +79,7 @@ class SocialActionType extends AbstractType
'class' => Goal::class,
'required' => false,
'multiple' => true,
+ 'attr' => ['class' => 'select2'],
'choice_label' => function (Goal $g) {
return $this->translatableStringHelper->localize($g->getTitle());
},
@@ -83,6 +89,7 @@ class SocialActionType extends AbstractType
'class' => Evaluation::class,
'required' => false,
'multiple' => true,
+ 'attr' => ['class' => 'select2'],
'choice_label' => function (Evaluation $e) {
return $this->translatableStringHelper->localize($e->getTitle());
},
diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
index 5cbe4a0c2..5aa76fbc6 100644
--- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
+++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
@@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -41,6 +42,10 @@ class SocialIssueType extends AbstractType
'required' => false,
'choice_label' => fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle()),
])
+ ->add('ordering', NumberType::class, [
+ 'required' => true,
+ 'scale' => 6,
+ ])
->add('desactivationDate', ChillDateType::class, [
'label' => 'goal.desactivationDate',
'required' => false,
diff --git a/src/Bundle/ChillPersonBundle/Menu/AdminAccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AdminAccompanyingCourseMenuBuilder.php
index eb83d8471..afd9f9484 100644
--- a/src/Bundle/ChillPersonBundle/Menu/AdminAccompanyingCourseMenuBuilder.php
+++ b/src/Bundle/ChillPersonBundle/Menu/AdminAccompanyingCourseMenuBuilder.php
@@ -39,7 +39,7 @@ class AdminAccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
->setAttribute('class', 'list-group-item-header')
->setExtras([
'order' => 2200,
- 'icons' => ['road'],
+ 'icons' => ['random'],
]);
$menu->addChild('person_admin.closing motives', [
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig
index e2e21fca8..d159c7193 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig
@@ -5,13 +5,9 @@
{% block table_entities_thead_tr %}
{{ 'Id'|trans }} |
{{ 'Title'|trans }} |
- {{ 'Parent'|trans }} |
{{ 'Social issue'|trans }} |
- {{ 'Results'|trans }} |
- {{ 'Goals'|trans }} |
- {{ 'Evaluations'|trans }} |
+ {{ 'Ordering'|trans }} |
{{ 'goal.desactivationDate'|trans }} |
- {{ 'socialAction.defaultNotificationDelay'|trans }} |
|
{% endblock %}
@@ -19,50 +15,14 @@
{% for entity in entities %}
{{ entity.id }} |
- {{ entity.title|localize_translatable_string }} |
-
- {% if entity.parent is not null %}
- {{ entity.parent.title|localize_translatable_string }}
- {% endif %}
- |
-
- {% for e in entity.issue %}
- {{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
- {% endfor %}
- |
-
- {% for e in entity.results %}
- {{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
- {% endfor %}
- |
-
- {% for e in entity.goals %}
- {{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
- {% endfor %}
- |
-
- {% for e in entity.evaluations %}
- {{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
- {% endfor %}
- |
+ {{ entity|chill_entity_render_box }} |
+ {{ entity.issue|chill_entity_render_box }} |
+ {{ entity.ordering }} |
{% if entity.desactivationDate is not null %}
{{ entity.desactivationDate|date('Y-m-d') }}
{% endif %}
|
-
- {% if entity.defaultNotificationDelay is not null %}
- {% if entity.defaultNotificationDelay.d > 0 %}
- {{ entity.defaultNotificationDelay.d }} {{'days'|trans}}
- {% endif %}
- {% if entity.defaultNotificationDelay.m > 0 %}
- {{ entity.defaultNotificationDelay.m }} {{'months'|trans}}
- {% endif %}
- {% if entity.defaultNotificationDelay.y > 0 %}
- {{ entity.defaultNotificationDelay.y }} {{'years'|trans}}
- {% endif %}
- {% endif %}
- |
-
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/index.html.twig
index 4682a5464..60cd9f4a5 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/index.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/index.html.twig
@@ -5,7 +5,7 @@
{% block table_entities_thead_tr %}
{{ 'Id'|trans }} |
{{ 'Title'|trans }} |
- {{ 'Parent'|trans }} |
+ {{ 'Ordering'|trans }} |
{{ 'goal.desactivationDate'|trans }} |
|
{% endblock %}
@@ -14,12 +14,10 @@
{% for entity in entities %}
{{ entity.id }} |
- {{ entity.title|localize_translatable_string }} |
- {% if entity.parent is not null %}
- {{ entity.parent.title|localize_translatable_string }}
- {% endif %}
+ {{ entity|chill_entity_render_box }}
|
+ {{ entity.ordering }} |
{% if entity.desactivationDate is not null %}
{{ entity.desactivationDate|date('Y-m-d') }}
diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
index b6e386ed8..c2c27f58a 100644
--- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
@@ -462,7 +462,7 @@ socialAction:
household:
allowHolder: Peut être titulaire
- shareHousehold: Peut être partagé
+ shareHousehold: Membre du ménage
relation:
title: Premier membre
From aec01df20225dcac630c4bb7a8ca16086509268e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Fri, 13 May 2022 16:00:34 +0200
Subject: [PATCH 46/49] admin users: filter by name or email
---
.../Controller/UserController.php | 57 ++++++++++++++-----
.../Repository/UserRepository.php | 23 ++++++--
2 files changed, 63 insertions(+), 17 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php
index af4c3b6ad..484d878ea 100644
--- a/src/Bundle/ChillMainBundle/Controller/UserController.php
+++ b/src/Bundle/ChillMainBundle/Controller/UserController.php
@@ -19,6 +19,7 @@ use Chill\MainBundle\Form\UserCurrentLocationType;
use Chill\MainBundle\Form\UserPasswordType;
use Chill\MainBundle\Form\UserType;
use Chill\MainBundle\Pagination\PaginatorInterface;
+use Chill\MainBundle\Repository\UserRepository;
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
use LogicException;
@@ -38,24 +39,62 @@ class UserController extends CRUDController
{
public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
- private FilterOrderHelperFactoryInterface $filterOrderHelperFactory;
private LoggerInterface $logger;
private UserPasswordEncoderInterface $passwordEncoder;
+ private UserRepository $userRepository;
+
private ValidatorInterface $validator;
+
public function __construct(
LoggerInterface $chillLogger,
ValidatorInterface $validator,
UserPasswordEncoderInterface $passwordEncoder,
- FilterOrderHelperFactoryInterface $filterOrderHelperFactory
+ UserRepository $userRepository
) {
$this->logger = $chillLogger;
+ $this->userRepository = $userRepository;
$this->validator = $validator;
$this->passwordEncoder = $passwordEncoder;
- $this->filterOrderHelperFactory = $filterOrderHelperFactory;
+ }
+
+ protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int
+ {
+ if (!$filterOrder instanceof FilterOrderHelper) {
+ return parent::countEntities($action, $request, $filterOrder);
+ }
+
+ if (null === $filterOrder->getQueryString()) {
+ return parent::countEntities($action, $request, $filterOrder);
+ }
+
+ return $this->userRepository->countByUsernameOrEmail($filterOrder->getQueryString());
+ }
+
+ protected function getQueryResult(
+ string $action,
+ Request $request,
+ int $totalItems,
+ PaginatorInterface $paginator,
+ ?FilterOrderHelper $filterOrder = null
+ ) {
+ if (0 === $totalItems) {
+ return [];
+ }
+
+ if (!$filterOrder instanceof FilterOrderHelper) {
+ return parent::getQueryResult($action, $request, $totalItems, $paginator, $filterOrder);
+ }
+
+ if (null === $filterOrder->getQueryString()) {
+ return parent::getQueryResult($action, $request, $totalItems, $paginator, $filterOrder);
+ }
+
+ return $this->userRepository->findByUsernameOrEmail($filterOrder->getQueryString(), ['usernameCanonical' => 'ASC'],
+ $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber());
}
/**
@@ -230,15 +269,6 @@ class UserController extends CRUDController
->build();
}
- protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int
- {
- if (null === $filterOrder) {
- throw new LogicException('filterOrder should not be null');
- }
-
- return parent::countEntities($action, $request, $filterOrder);
- }
-
protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface
{
// for "new", add special config
@@ -288,7 +318,8 @@ class UserController extends CRUDController
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
{
- $query->addOrderBy('e.usernameCanonical', 'ASC');
+ $query
+ ->addOrderBy('e.usernameCanonical', 'ASC');
return parent::orderQuery($action, $query, $request, $paginator);
}
diff --git a/src/Bundle/ChillMainBundle/Repository/UserRepository.php b/src/Bundle/ChillMainBundle/Repository/UserRepository.php
index fc3a6e187..79ab5fc3d 100644
--- a/src/Bundle/ChillMainBundle/Repository/UserRepository.php
+++ b/src/Bundle/ChillMainBundle/Repository/UserRepository.php
@@ -83,10 +83,24 @@ final class UserRepository implements ObjectRepository
return $this->findBy(['enabled' => true], $orderBy, $limit, $offset);
}
- public function findByUsernameOrEmail(string $pattern)
+ public function findByUsernameOrEmail(string $pattern, ?array $orderBy = [], ?int $limit = null, ?int $offset = null): array
{
$qb = $this->queryByUsernameOrEmail($pattern);
+ $qb->select('u');
+
+ if (null !== $limit) {
+ $qb->setMaxResults($limit);
+ }
+
+ if (null !== $offset) {
+ $qb->setFirstResult($offset);
+ }
+
+ foreach ($orderBy as $field => $order) {
+ $qb->addOrderBy('u.'.$field, $order);
+ }
+
return $qb->getQuery()->getResult();
}
@@ -164,13 +178,14 @@ final class UserRepository implements ObjectRepository
private function queryByUsernameOrEmail(string $pattern): QueryBuilder
{
- $qb = $this->entityManager->createQueryBuilder('u');
+ $qb = $this->entityManager->createQueryBuilder()->from(User::class, 'u');
$searchByPattern = $qb->expr()->orX();
$searchByPattern
- ->add($qb->expr()->eq('u.usernameCanonical', 'LOWER(UNACCENT(:pattern))'))
- ->add($qb->expr()->eq('u.emailCanonical', 'LOWER(UNACCENT(:pattern))'));
+ ->add($qb->expr()->like('u.usernameCanonical', 'CONCAT(\'%\', LOWER(UNACCENT(:pattern)), \'%\')'))
+ ->add($qb->expr()->like('u.emailCanonical', 'CONCAT(\'%\', LOWER(UNACCENT(:pattern)), \'%\')'));
+
$qb
->where($searchByPattern)
From 2a5bb282107ac7dd3588ada4acc7f37d797ee23e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Fri, 13 May 2022 16:05:08 +0200
Subject: [PATCH 47/49] fix typo in tests
---
.../ChillMainBundle/Tests/Controller/CenterControllerTest.php | 2 +-
.../ChillMainBundle/Tests/Controller/ScopeControllerTest.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/CenterControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/CenterControllerTest.php
index b5bb012a2..e10879760 100644
--- a/src/Bundle/ChillMainBundle/Tests/Controller/CenterControllerTest.php
+++ b/src/Bundle/ChillMainBundle/Tests/Controller/CenterControllerTest.php
@@ -53,7 +53,7 @@ final class CenterControllerTest extends WebTestCase
);
// Edit the entity
- $crawler = $client->click($crawler->selectLink('Modifier')->link());
+ $crawler = $client->click($crawler->selectLink('modifier')->link());
$form = $crawler->selectButton('Mettre à jour')->form([
'chill_mainbundle_center[name]' => 'Foo',
diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/ScopeControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/ScopeControllerTest.php
index 806153220..8530308e3 100644
--- a/src/Bundle/ChillMainBundle/Tests/Controller/ScopeControllerTest.php
+++ b/src/Bundle/ChillMainBundle/Tests/Controller/ScopeControllerTest.php
@@ -61,7 +61,7 @@ final class ScopeControllerTest extends WebTestCase
);
// Edit the entity
- $crawler = $client->click($crawler->selectLink('Modifier')->link());
+ $crawler = $client->click($crawler->selectLink('modifier')->link());
$form = $crawler->selectButton('Mettre à jour')->form([
'chill_mainbundle_scope[name][fr]' => 'Foo',
From 89a700ff61bbb596d196a0820449716de2e665eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Fri, 13 May 2022 16:05:38 +0200
Subject: [PATCH 48/49] fix cs
---
.../Entity/DocumentCategory.php | 14 ++--
.../Controller/UserController.php | 80 +++++++++----------
.../Repository/UserRepository.php | 3 +-
3 files changed, 48 insertions(+), 49 deletions(-)
diff --git a/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php b/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php
index 884447599..69af75f42 100644
--- a/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php
+++ b/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php
@@ -87,6 +87,13 @@ class DocumentCategory
return $this->name;
}
+ public function setBundleId($id): self
+ {
+ $this->bundleId = $id;
+
+ return $this;
+ }
+
public function setDocumentClass($documentClass): self
{
$this->documentClass = $documentClass;
@@ -100,11 +107,4 @@ class DocumentCategory
return $this;
}
-
- public function setBundleId($id): self
- {
- $this->bundleId = $id;
-
- return $this;
- }
}
diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php
index 484d878ea..068bd9f73 100644
--- a/src/Bundle/ChillMainBundle/Controller/UserController.php
+++ b/src/Bundle/ChillMainBundle/Controller/UserController.php
@@ -21,8 +21,6 @@ use Chill\MainBundle\Form\UserType;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Chill\MainBundle\Repository\UserRepository;
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
-use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
-use LogicException;
use Psr\Log\LoggerInterface;
use RuntimeException;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@@ -39,7 +37,6 @@ class UserController extends CRUDController
{
public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
-
private LoggerInterface $logger;
private UserPasswordEncoderInterface $passwordEncoder;
@@ -48,7 +45,6 @@ class UserController extends CRUDController
private ValidatorInterface $validator;
-
public function __construct(
LoggerInterface $chillLogger,
ValidatorInterface $validator,
@@ -61,42 +57,6 @@ class UserController extends CRUDController
$this->passwordEncoder = $passwordEncoder;
}
- protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int
- {
- if (!$filterOrder instanceof FilterOrderHelper) {
- return parent::countEntities($action, $request, $filterOrder);
- }
-
- if (null === $filterOrder->getQueryString()) {
- return parent::countEntities($action, $request, $filterOrder);
- }
-
- return $this->userRepository->countByUsernameOrEmail($filterOrder->getQueryString());
- }
-
- protected function getQueryResult(
- string $action,
- Request $request,
- int $totalItems,
- PaginatorInterface $paginator,
- ?FilterOrderHelper $filterOrder = null
- ) {
- if (0 === $totalItems) {
- return [];
- }
-
- if (!$filterOrder instanceof FilterOrderHelper) {
- return parent::getQueryResult($action, $request, $totalItems, $paginator, $filterOrder);
- }
-
- if (null === $filterOrder->getQueryString()) {
- return parent::getQueryResult($action, $request, $totalItems, $paginator, $filterOrder);
- }
-
- return $this->userRepository->findByUsernameOrEmail($filterOrder->getQueryString(), ['usernameCanonical' => 'ASC'],
- $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber());
- }
-
/**
* @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter",
* name="admin_user_add_groupcenter")
@@ -269,6 +229,19 @@ class UserController extends CRUDController
->build();
}
+ protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int
+ {
+ if (!$filterOrder instanceof FilterOrderHelper) {
+ return parent::countEntities($action, $request, $filterOrder);
+ }
+
+ if (null === $filterOrder->getQueryString()) {
+ return parent::countEntities($action, $request, $filterOrder);
+ }
+
+ return $this->userRepository->countByUsernameOrEmail($filterOrder->getQueryString());
+ }
+
protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface
{
// for "new", add special config
@@ -304,6 +277,33 @@ class UserController extends CRUDController
return parent::generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters);
}
+ protected function getQueryResult(
+ string $action,
+ Request $request,
+ int $totalItems,
+ PaginatorInterface $paginator,
+ ?FilterOrderHelper $filterOrder = null
+ ) {
+ if (0 === $totalItems) {
+ return [];
+ }
+
+ if (!$filterOrder instanceof FilterOrderHelper) {
+ return parent::getQueryResult($action, $request, $totalItems, $paginator, $filterOrder);
+ }
+
+ if (null === $filterOrder->getQueryString()) {
+ return parent::getQueryResult($action, $request, $totalItems, $paginator, $filterOrder);
+ }
+
+ return $this->userRepository->findByUsernameOrEmail(
+ $filterOrder->getQueryString(),
+ ['usernameCanonical' => 'ASC'],
+ $paginator->getItemsPerPage(),
+ $paginator->getCurrentPageFirstItemNumber()
+ );
+ }
+
protected function onPrePersist(string $action, $entity, FormInterface $form, Request $request)
{
// for "new", encode the password
diff --git a/src/Bundle/ChillMainBundle/Repository/UserRepository.php b/src/Bundle/ChillMainBundle/Repository/UserRepository.php
index 79ab5fc3d..7b7d5d2ab 100644
--- a/src/Bundle/ChillMainBundle/Repository/UserRepository.php
+++ b/src/Bundle/ChillMainBundle/Repository/UserRepository.php
@@ -98,7 +98,7 @@ final class UserRepository implements ObjectRepository
}
foreach ($orderBy as $field => $order) {
- $qb->addOrderBy('u.'.$field, $order);
+ $qb->addOrderBy('u.' . $field, $order);
}
return $qb->getQuery()->getResult();
@@ -186,7 +186,6 @@ final class UserRepository implements ObjectRepository
->add($qb->expr()->like('u.usernameCanonical', 'CONCAT(\'%\', LOWER(UNACCENT(:pattern)), \'%\')'))
->add($qb->expr()->like('u.emailCanonical', 'CONCAT(\'%\', LOWER(UNACCENT(:pattern)), \'%\')'));
-
$qb
->where($searchByPattern)
->setParameter('pattern', $pattern);
From bb18082c3a34e96c37ba33e26f08e6cfc2b7641a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Fri, 13 May 2022 16:07:33 +0200
Subject: [PATCH 49/49] fix type hinting
---
.../ChillPersonBundle/Controller/ClosingMotiveController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/ClosingMotiveController.php b/src/Bundle/ChillPersonBundle/Controller/ClosingMotiveController.php
index cf1436b99..8e9b9d14d 100644
--- a/src/Bundle/ChillPersonBundle/Controller/ClosingMotiveController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/ClosingMotiveController.php
@@ -22,7 +22,7 @@ use Symfony\Component\HttpFoundation\Request;
class ClosingMotiveController extends CRUDController
{
/**
- * @param \Chill\MainBundle\CRUD\Controller\string|string $action
+ * @param string $action
*/
protected function createEntity($action, Request $request): object
{
| | |