From 588f02cdf4d86dece1dd93fd13c5209af57bbc10 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 22 Oct 2024 14:39:17 +0200 Subject: [PATCH] Take Null value for gender into account and fix OnTheFly makeFetch --- .../ChillMainBundle/translations/messages.fr.yml | 1 + .../Resources/public/vuejs/_api/OnTheFly.js | 12 ++++++------ .../vuejs/_components/Entity/PersonRenderBox.vue | 2 +- .../Resources/views/Entity/person.html.twig | 2 +- .../views/Person/list_with_period.html.twig | 6 +++--- .../Resources/views/Person/view.html.twig | 7 +++++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 85268a06a..3e6ea2011 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -713,5 +713,6 @@ news: gender: genderTranslation: traduction grammaticale + not defined: Non défini diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js index d8f5700ff..bc8ce60e2 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js @@ -24,12 +24,12 @@ const getCivilities = () => throw Error('Error with request resource response'); }); -const getGenders = () => - makeFetch("GET", '/api/1.0/main/gender.json'). - .then(response => { - if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); - }); +const getGenders = () => makeFetch("GET", '/api/1.0/main/gender.json') + // .then(response => { + // console.log(response) + // if (response.ok) { return response.json(); } + // throw Error('Error with request resource response'); + // }); const getCentersForPersonCreation = () => makeFetch('GET', '/api/1.0/person/creation/authorized-centers', null); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue index df3e77897..26f13d65f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue @@ -39,7 +39,7 @@

{%- if options['addAge'] -%} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig index d07799de2..5cf0d7ea0 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig @@ -45,7 +45,7 @@

{% if acp.requestoranonymous == false and acp.requestorPerson is same as(person) %} - {{ 'Requestor'|trans({'gender': person.gender}) }} + {{ 'Requestor'|trans({'gender': person.gender ? person.gender.genderTranslation.value : 'neutral'}) }} {% endif %} @@ -119,7 +119,7 @@ {% endif %} {% endfor %} {% if participating %} - {{ 'person.And himself'|trans({'gender': person.gender.genderTranslation.value}) }} + {{ 'person.And himself'|trans({'gender': person.gender ? person.gender.genderTranslation.value : 'neutral'}) }} {% endif %}
@@ -131,7 +131,7 @@

{% if acp.requestorPerson is not null %} - {{ 'Requestor'|trans({'gender': acp.requestorPerson.gender.genderTranslation.value}) }} + {{ 'Requestor'|trans({'gender': acp.requestorPerson.gender ? person.gender.genderTranslation.value : 'neutral'}) }} {% else %} {{ 'Requestor'|trans({'gender': 'other'})}} {% endif %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig index 2f9844d6a..ba1fbc372 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig @@ -73,8 +73,11 @@ This view should receive those arguments: {% endfor %}
{{ 'Gender'|trans }} :
-
{{ ( person.gender.label|localize_translatable_string ) }}
- + {% if person.gender %} +
{{ ( person.gender.label|localize_translatable_string ) }}
+ {% else %} +
{{ 'gender.not defined'|trans }}
+ {% endif %}