add ordering on some social work + minor improves

This commit is contained in:
Julien Fastré 2022-05-13 15:36:20 +02:00
parent b26fcc4566
commit a9df9f4880
8 changed files with 24 additions and 54 deletions

View File

@ -19,7 +19,7 @@ class SocialActionController extends CRUDController
{ {
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) 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); return parent::orderQuery($action, $query, $request, $paginator);
} }

View File

@ -19,7 +19,7 @@ class SocialIssueController extends CRUDController
{ {
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) 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); return parent::orderQuery($action, $query, $request, $paginator);
} }

View File

@ -22,6 +22,7 @@ use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@ -60,11 +61,15 @@ class SocialActionType extends AbstractType
return $this->translatableStringHelper->localize($issue->getTitle()); return $this->translatableStringHelper->localize($issue->getTitle());
}, },
]) ])
->add('ordering', NumberType::class, [
'required' => true,
'scale' => 6,
])
->add('results', EntityType::class, [ ->add('results', EntityType::class, [
'class' => Result::class, 'class' => Result::class,
'required' => false, 'required' => false,
'multiple' => true, 'multiple' => true,
'attr' => ['class' => 'select2'],
'choice_label' => function (Result $r) { 'choice_label' => function (Result $r) {
return $this->translatableStringHelper->localize($r->getTitle()); return $this->translatableStringHelper->localize($r->getTitle());
}, },
@ -74,6 +79,7 @@ class SocialActionType extends AbstractType
'class' => Goal::class, 'class' => Goal::class,
'required' => false, 'required' => false,
'multiple' => true, 'multiple' => true,
'attr' => ['class' => 'select2'],
'choice_label' => function (Goal $g) { 'choice_label' => function (Goal $g) {
return $this->translatableStringHelper->localize($g->getTitle()); return $this->translatableStringHelper->localize($g->getTitle());
}, },
@ -83,6 +89,7 @@ class SocialActionType extends AbstractType
'class' => Evaluation::class, 'class' => Evaluation::class,
'required' => false, 'required' => false,
'multiple' => true, 'multiple' => true,
'attr' => ['class' => 'select2'],
'choice_label' => function (Evaluation $e) { 'choice_label' => function (Evaluation $e) {
return $this->translatableStringHelper->localize($e->getTitle()); return $this->translatableStringHelper->localize($e->getTitle());
}, },

View File

@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@ -41,6 +42,10 @@ class SocialIssueType extends AbstractType
'required' => false, 'required' => false,
'choice_label' => fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle()), 'choice_label' => fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle()),
]) ])
->add('ordering', NumberType::class, [
'required' => true,
'scale' => 6,
])
->add('desactivationDate', ChillDateType::class, [ ->add('desactivationDate', ChillDateType::class, [
'label' => 'goal.desactivationDate', 'label' => 'goal.desactivationDate',
'required' => false, 'required' => false,

View File

@ -39,7 +39,7 @@ class AdminAccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
->setAttribute('class', 'list-group-item-header') ->setAttribute('class', 'list-group-item-header')
->setExtras([ ->setExtras([
'order' => 2200, 'order' => 2200,
'icons' => ['road'], 'icons' => ['random'],
]); ]);
$menu->addChild('person_admin.closing motives', [ $menu->addChild('person_admin.closing motives', [

View File

@ -5,13 +5,9 @@
{% block table_entities_thead_tr %} {% block table_entities_thead_tr %}
<th>{{ 'Id'|trans }}</th> <th>{{ 'Id'|trans }}</th>
<th>{{ 'Title'|trans }}</th> <th>{{ 'Title'|trans }}</th>
<th>{{ 'Parent'|trans }}</th>
<th>{{ 'Social issue'|trans }}</th> <th>{{ 'Social issue'|trans }}</th>
<th>{{ 'Results'|trans }}</th> <th>{{ 'Ordering'|trans }}</th>
<th>{{ 'Goals'|trans }}</th>
<th>{{ 'Evaluations'|trans }}</th>
<th>{{ 'goal.desactivationDate'|trans }}</th> <th>{{ 'goal.desactivationDate'|trans }}</th>
<th>{{ 'socialAction.defaultNotificationDelay'|trans }}</th>
<th>&nbsp;</th> <th>&nbsp;</th>
{% endblock %} {% endblock %}
@ -19,50 +15,14 @@
{% for entity in entities %} {% for entity in entities %}
<tr> <tr>
<td>{{ entity.id }}</td> <td>{{ entity.id }}</td>
<td>{{ entity.title|localize_translatable_string }}</td> <td>{{ entity|chill_entity_render_box }}</td>
<td> <td>{{ entity.issue|chill_entity_render_box }}</td>
{% if entity.parent is not null %} <td>{{ entity.ordering }}</td>
{{ entity.parent.title|localize_translatable_string }}
{% endif %}
</td>
<td>
{% for e in entity.issue %}
{{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
{% endfor %}
</td>
<td>
{% for e in entity.results %}
{{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
{% endfor %}
</td>
<td>
{% for e in entity.goals %}
{{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
{% endfor %}
</td>
<td>
{% for e in entity.evaluations %}
{{ e.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
{% endfor %}
</td>
<td> <td>
{% if entity.desactivationDate is not null %} {% if entity.desactivationDate is not null %}
{{ entity.desactivationDate|date('Y-m-d') }} {{ entity.desactivationDate|date('Y-m-d') }}
{% endif %} {% endif %}
</td> </td>
<td>
{% 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 %}
</td>
<td> <td>
<ul class="record_actions"> <ul class="record_actions">
<li> <li>

View File

@ -5,7 +5,7 @@
{% block table_entities_thead_tr %} {% block table_entities_thead_tr %}
<th>{{ 'Id'|trans }}</th> <th>{{ 'Id'|trans }}</th>
<th>{{ 'Title'|trans }}</th> <th>{{ 'Title'|trans }}</th>
<th>{{ 'Parent'|trans }}</th> <th>{{ 'Ordering'|trans }}</th>
<th>{{ 'goal.desactivationDate'|trans }}</th> <th>{{ 'goal.desactivationDate'|trans }}</th>
<th>&nbsp;</th> <th>&nbsp;</th>
{% endblock %} {% endblock %}
@ -14,12 +14,10 @@
{% for entity in entities %} {% for entity in entities %}
<tr> <tr>
<td>{{ entity.id }}</td> <td>{{ entity.id }}</td>
<td>{{ entity.title|localize_translatable_string }}</td>
<td> <td>
{% if entity.parent is not null %} {{ entity|chill_entity_render_box }}
{{ entity.parent.title|localize_translatable_string }}
{% endif %}
</td> </td>
<td>{{ entity.ordering }}</td>
<td> <td>
{% if entity.desactivationDate is not null %} {% if entity.desactivationDate is not null %}
{{ entity.desactivationDate|date('Y-m-d') }} {{ entity.desactivationDate|date('Y-m-d') }}

View File

@ -462,7 +462,7 @@ socialAction:
household: household:
allowHolder: Peut être titulaire allowHolder: Peut être titulaire
shareHousehold: Peut être partagé shareHousehold: Membre du ménage
relation: relation:
title: Premier membre title: Premier membre