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] 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 %} -