diff --git a/CHANGELOG.md b/CHANGELOG.md index dcd149841..4a2f8dfae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to * [parcours]: component added to change the opening date of a parcours (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/411) * [search]: listing of parcours display changed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/410) * [user]: page with accompanying periods to which is user is referent (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/408) +* [person] age added to renderstring + renderbox/ vue component created to display person text (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/389) ## Test releases @@ -35,7 +36,6 @@ and this project adheres to * [parcours] comments truncated if too long + link added (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/406) * [person]: possibility to add person resources (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/382) * [person ressources]: module added -* [parcours] bugfix if deathdate is not defined (eg. for a thirdparty) parcours is still displayed. Gave error before. ### test release 2022-01-24 diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue index f5057eb25..45483dc95 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue @@ -1,45 +1,48 @@ diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list_recent.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list_recent.html.twig index 0f426c5a9..e8be2c49e 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list_recent.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list_recent.html.twig @@ -48,7 +48,7 @@
  • {{ 'Participants'|trans ~ ' : ' }} {% for p in activity.personsAssociated %} - {{ p|chill_entity_render_box }} + {{ p|chill_entity_render_box({'addAgeBadge': true}) }} {% endfor %}
  • diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/badge.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/badge.scss index 4d213645e..bfd43064b 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/badge.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/badge.scss @@ -12,6 +12,7 @@ display: block; top: calc(50% - 7px); right: 10px; + line-height: 11px; } } @@ -62,14 +63,19 @@ ul.list-suggest { & span:hover { color: $chill-l-gray; } + .person-text { + span { + padding-left: 0px; + } + } } } &.remove-items { li { position: relative; - span { + & > span { display: block; - padding-right: .75rem; + padding-right: 1.75rem; @include remove_link; } } diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js index 1ab8eb29a..c1eac0b06 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js @@ -61,14 +61,15 @@ const messages = { woman: "Née le" }, deathdate: "Date de décès", - years_old: "ans", household_without_address: "Le ménage de l'usager est sans adresse", no_data: "Aucune information renseignée", type: { thirdparty: "Tiers", person: "Usager" }, - holder: "Titulaire" + holder: "Titulaire", + years_old: "an | {n} an | {n} ans", + } } }; diff --git a/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig b/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig index 1f29bfe7a..16e9cbf02 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig @@ -42,6 +42,3 @@ {% endif %} > - -{{ encore_entry_script_tags('vue_onthefly') }} -{{ encore_entry_link_tags('vue_onthefly') }} diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index a123ce405..ef48414e0 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -13,6 +13,7 @@ {{ encore_entry_link_tags('mod_ckeditor5') }} {{ encore_entry_link_tags('chill') }} {{ encore_entry_link_tags('mod_blur') }} + {{ encore_entry_link_tags('vue_onthefly') }} {% block css %}{% endblock %} @@ -94,6 +95,7 @@ {{ encore_entry_script_tags('mod_ckeditor5') }} {{ encore_entry_script_tags('mod_blur') }} {{ encore_entry_script_tags('chill') }} + {{ encore_entry_script_tags('vue_onthefly') }} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig index d45ba40ca..7f2fb0177 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig @@ -31,7 +31,7 @@
  • {{ 'Participants'|trans ~ ' : ' }} {% for p in w.persons %} - {{ p|chill_entity_render_box }} + {{ p|chill_entity_render_box({'addAgeBadge': true}) }} {% endfor %}
  • diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig index 622318643..9bee504a9 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig @@ -11,6 +11,7 @@ * addCenter bool * hLevel integer * addDeath bool + * addAgeBadge bool * address_multiline bool * customButtons [ 'before' Twig\Markup, (injected with macro) @@ -40,6 +41,11 @@ {%- endfor -%} {%- endif -%} + {%- if options['addAgeBadge'] -%} + {% if person.age is not null and person.deathDate is null %} + ({{- 'years_old'|trans({ 'age': person.age }) -}}) + {% endif %} + {% endif %} {% endmacro raw %} {% macro label(person, options) %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/_render_member.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/_render_member.html.twig index 5b41a15e3..fdd1e0717 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/_render_member.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/_render_member.html.twig @@ -14,6 +14,7 @@ 'render': 'label', 'addLink': true, 'addInfo': true, + 'addAgeBadge': true, 'customArea': { 'afterLabel': _self.addHolder(member.holder) } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 568926f79..6288663e2 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -179,11 +179,13 @@ class PersonJsonNormalizer implements return [ 'type' => 'person', 'id' => $person->getId(), - 'text' => $this->render->renderString($person), + 'text' => $this->render->renderString($person, ['addAge' => false]), + 'textAge' => $this->render->renderString($person, ['addAge' => true]), 'firstName' => $person->getFirstName(), 'lastName' => $person->getLastName(), 'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $context), 'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $context), + 'age' => $this->normalizer->normalize($person->getAge(), $format, $context), 'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($person), $format, $context), 'phonenumber' => $person->getPhonenumber(), 'mobilenumber' => $person->getMobilenumber(), diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php index 6464500c2..0898bc32a 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender; use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; use Chill\PersonBundle\Entity\Person; use Symfony\Component\Templating\EngineInterface; +use Symfony\Contracts\Translation\TranslatorInterface; use function array_key_exists; @@ -27,12 +28,16 @@ class PersonRender extends AbstractChillEntityRender private EngineInterface $engine; + private TranslatorInterface $translator; + public function __construct( ConfigPersonAltNamesHelper $configAltNamesHelper, - EngineInterface $engine + EngineInterface $engine, + TranslatorInterface $translator ) { $this->configAltNamesHelper = $configAltNamesHelper; $this->engine = $engine; + $this->translator = $translator; } /** @@ -53,6 +58,7 @@ class PersonRender extends AbstractChillEntityRender 'customButtons' => $options['customButtons'] ?? [], 'customArea' => $options['customArea'] ?? [], 'addDeath' => $options['addDeath'] ?? true, + 'addAgeBadge' => $options['addAgeBadge'] ?? false, ]; return @@ -70,6 +76,13 @@ class PersonRender extends AbstractChillEntityRender */ public function renderString($person, array $options): string { + $options = array_merge(['addAge' => true], $options); + + if (null !== $person->getAge() && $person->getDeathDate() === null && $options['addAge']) { + return $person->getFirstName() . ' ' . $person->getLastName() + . $this->addAltNames($person, false) . ' (' . $this->translator->trans('years_old', ['age' => $person->getAge()]) . ')'; + } + return $person->getFirstName() . ' ' . $person->getLastName() . $this->addAltNames($person, false); }