admin: adapt social work form type and templates

This commit is contained in:
nobohan 2022-05-11 11:50:17 +02:00
parent 629dbb9137
commit fa458c54ec
6 changed files with 73 additions and 1 deletions

View File

@ -15,6 +15,7 @@ use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\SocialWork\Goal; use Chill\PersonBundle\Entity\SocialWork\Goal;
use Chill\PersonBundle\Entity\SocialWork\Result;
use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; 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, [ ->add('desactivationDate', ChillDateType::class, [
'required' => false, 'required' => false,
'label' => 'goal.desactivationDate', 'label' => 'goal.desactivationDate',

View File

@ -15,6 +15,9 @@ use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\DateIntervalType; use Chill\MainBundle\Form\Type\DateIntervalType;
use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Chill\MainBundle\Templating\TranslatableStringHelper; 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\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;
@ -57,6 +60,34 @@ class SocialActionType extends AbstractType
return $this->translatableStringHelper->localize($issue->getTitle()); 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, [ ->add('defaultNotificationDelay', DateIntervalType::class, [
'label' => 'socialAction.defaultNotificationDelay', 'label' => 'socialAction.defaultNotificationDelay',
'required' => false, 'required' => false,

View File

@ -6,6 +6,7 @@
<th>{{ 'Id'|trans }}</th> <th>{{ 'Id'|trans }}</th>
<th>{{ 'Title'|trans }}</th> <th>{{ 'Title'|trans }}</th>
<th>{{ 'Social actions'|trans }}</th> <th>{{ 'Social actions'|trans }}</th>
<th>{{ 'goal.results'|trans }}</th>
<th>{{ 'goal.desactivationDate'|trans }}</th> <th>{{ 'goal.desactivationDate'|trans }}</th>
<th>&nbsp;</th> <th>&nbsp;</th>
{% endblock %} {% endblock %}
@ -21,6 +22,11 @@
{% endfor %} {% endfor %}
</td> </td>
<td> <td>
{% for sa in entity.results %}
{{ sa.title|localize_translatable_string }}{% if not loop.last %},{% else %}.{% endif %}
{% endfor %}
</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 %}

View File

@ -9,7 +9,7 @@
{% block crud_content_form_rows %} {% block crud_content_form_rows %}
{% for f in form %} {% 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'}}) }} {{ form_row(f, { 'attr':{'disabled':'disabled'}}) }}
{% else %} {% else %}
{{ form_row(f) }} {{ form_row(f) }}

View File

@ -6,6 +6,10 @@
<th>{{ 'Id'|trans }}</th> <th>{{ 'Id'|trans }}</th>
<th>{{ 'Title'|trans }}</th> <th>{{ 'Title'|trans }}</th>
<th>{{ 'Parent'|trans }}</th> <th>{{ 'Parent'|trans }}</th>
<th>{{ 'Social issue'|trans }}</th>
<th>{{ 'Results'|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>{{ 'socialAction.defaultNotificationDelay'|trans }}</th>
<th>&nbsp;</th> <th>&nbsp;</th>
@ -22,6 +26,26 @@
{% endif %} {% endif %}
</td> </td>
<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>
{% 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 %}

View File

@ -443,6 +443,7 @@ evaluation:
goal: goal:
desactivationDate: Date de désactivation desactivationDate: Date de désactivation
results: Résultats
socialAction: socialAction:
defaultNotificationDelay: Délai de notification par défaut defaultNotificationDelay: Délai de notification par défaut