From af3847366b58d0fe5b8125b19a2bd3b244f17132 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 27 Jan 2022 12:33:50 +0100 Subject: [PATCH 01/27] adding age in renderbox and renderstring, implementation of renderbox option in household summary --- .../Resources/views/Entity/person.html.twig | 6 ++++++ .../views/Household/_render_member.html.twig | 1 + .../Templating/Entity/PersonRender.php | 13 ++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig index 622318643..b60325bec 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/Templating/Entity/PersonRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php index 6464500c2..ff239f0d6 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,11 @@ class PersonRender extends AbstractChillEntityRender */ public function renderString($person, array $options): string { + if (null !== $person->getAge() && $person->getDeathDate() === null) { + 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); } From 6ef7d9b47b31dc98308ff64e7d96fd8d1ce72f37 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 27 Jan 2022 12:33:50 +0100 Subject: [PATCH 02/27] adding age in renderbox and renderstring, implementation of renderbox option in household summary --- .../Resources/views/Entity/person.html.twig | 6 ++++++ .../views/Household/_render_member.html.twig | 1 + .../Templating/Entity/PersonRender.php | 13 ++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig index 622318643..b60325bec 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/Templating/Entity/PersonRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php index 6464500c2..ff239f0d6 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,11 @@ class PersonRender extends AbstractChillEntityRender */ public function renderString($person, array $options): string { + if (null !== $person->getAge() && $person->getDeathDate() === null) { + 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); } From 8d663cdee6fca77d0ae6089ca80e61c507c846b1 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 27 Jan 2022 16:18:35 +0100 Subject: [PATCH 03/27] creation of vue component person-text --- .../Resources/public/vuejs/_js/i18n.js | 5 +- .../vuejs/_components/Entity/PersonText.vue | 53 +++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue 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/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue new file mode 100644 index 000000000..c9e98c55b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue @@ -0,0 +1,53 @@ + + + From 44d1535bfb48ab39c3a45d0926ccdf024fad6ca5 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 27 Jan 2022 16:18:54 +0100 Subject: [PATCH 04/27] style fixes --- .../Resources/public/chill/scss/badge.scss | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/badge.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/badge.scss index 4d213645e..48e3b25ae 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,6 +63,11 @@ ul.list-suggest { & span:hover { color: $chill-l-gray; } + .person-text { + span { + padding-left: 0px; + } + } } } &.remove-items { @@ -69,7 +75,7 @@ ul.list-suggest { position: relative; span { display: block; - padding-right: .75rem; + padding-right: 1.75rem; @include remove_link; } } From 8720cc730e5d6ef14a44a8e83a661dd960b2169e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 27 Jan 2022 16:19:19 +0100 Subject: [PATCH 05/27] implementation of person-text --- .../Activity/components/ConcernedGroups.vue | 56 +++--- .../ConcernedGroups/PersonBadge.vue | 20 +- .../components/PersonsAssociated.vue | 22 ++- .../components/Requestor.vue | 11 +- .../components/Resources.vue | 7 +- .../components/Positioning.vue | 9 +- .../_components/Entity/PersonRenderBox.vue | 184 +++++++++--------- 7 files changed, 166 insertions(+), 143 deletions(-) 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..29efe998d 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,47 @@ diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue index 3ea64bd67..202d5b376 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue @@ -27,7 +27,7 @@ :value="p.person.id" /> @@ -50,9 +50,9 @@
  • - {{ p.text }} -
  • -
+ + +
@@ -76,12 +76,14 @@ import {mapGetters, mapState} from 'vuex'; import ParticipationItem from "./PersonsAssociated/ParticipationItem.vue"; import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue'; +import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue'; export default { name: 'PersonsAssociated', components: { ParticipationItem, - AddPersons + AddPersons, + PersonText }, data() { return { @@ -110,15 +112,15 @@ export default { ) // filter persons appearing twice in requestor and resources .filter( - (e, index, suggested) => { + (e, index, suggested) => { for (let i = 0; i < suggested.length; i = i+1) { - if (i < index && e.id === suggested[i].id) { - return false - } + if (i < index && e.id === suggested[i].id) { + return false + } } return true; - } + } ) }), ...mapGetters([ diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue index a5d6791fb..8b13df7aa 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue @@ -136,9 +136,9 @@
  • - {{ p.text }} -
  • -
+ + +
@@ -162,6 +162,8 @@ import PersonRenderBox from '../../_components/Entity/PersonRenderBox.vue'; import ThirdPartyRenderBox from 'ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyRenderBox.vue'; import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue'; import { mapState } from 'vuex'; +import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue'; + export default { name: 'Requestor', @@ -170,7 +172,8 @@ export default { OnTheFly, PersonRenderBox, ThirdPartyRenderBox, - Confidential + Confidential, + PersonText }, props: ['isAnonymous'], data() { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue index ed1f85cf3..069e4d590 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue @@ -22,7 +22,7 @@
  • - {{ p.text }} +
@@ -45,12 +45,15 @@ import { mapState } from 'vuex'; import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue'; import ResourceItem from './Resources/ResourceItem.vue'; +import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue'; + export default { name: 'Resources', components: { AddPersons, - ResourceItem + ResourceItem, + PersonText }, data() { return { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Positioning.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Positioning.vue index 487fb230e..005d46122 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Positioning.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Positioning.vue @@ -6,12 +6,13 @@
-

{{ conc.person.text }}

+ +

@@ -202,24 +202,24 @@ export default { getUrl: function() { return `/fr/person/${this.person.id}/general`; }, - getAge: function() { - // TODO only one abstract function - if(this.person.birthdate && !this.person.deathdate){ - const birthday = new Date(this.person.birthdate.datetime) - const now = new Date() - return (now.getFullYear() - birthday.getFullYear()) - } else if(this.person.birthdate && this.person.deathdate){ - const birthday = new Date(this.person.birthdate.datetime) - const deathdate = new Date(this.person.deathdate.datetime) - return (deathdate.getFullYear() - birthday.getFullYear()) - } else if(!this.person.birthdate && this.person.deathdate.datetime) { - // todo: change this - return "Age unknown" - } else { - // todo: change this - return "Age unknown" - } - }, + // getAge: function() { + // // TODO only one abstract function + // if(this.person.birthdate && !this.person.deathdate){ + // const birthday = new Date(this.person.birthdate.datetime) + // const now = new Date() + // return (now.getFullYear() - birthday.getFullYear()) + // } else if(this.person.birthdate && this.person.deathdate){ + // const birthday = new Date(this.person.birthdate.datetime) + // const deathdate = new Date(this.person.deathdate.datetime) + // return (deathdate.getFullYear() - birthday.getFullYear()) + // } else if(!this.person.birthdate && this.person.deathdate.datetime) { + // // todo: change this + // return "Age unknown" + // } else { + // // todo: change this + // return "Age unknown" + // } + // }, getCurrentHouseholdUrl: function() { let returnPath = this.returnPath ? `?returnPath=${this.returnPath}` : ``; return `/fr/person/household/${this.person.current_household_id}/summary${returnPath}` diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue index d597f5205..0dde47235 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue @@ -21,7 +21,6 @@ export default { for(let i = 0; i < this.person.altNames.length; i++){ return this.person.altNames[i].label } - console.log(this.person.altNames) }, altNameKey: function() { for(let i = 0; i < this.person.altNames.length; i++){ From feaee8a0b10dff745a4086b404e4b79bc0b87ca6 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 28 Jan 2022 10:07:34 +0100 Subject: [PATCH 11/27] a few more implementations in twig templates --- .../Resources/views/Activity/list_recent.html.twig | 2 +- .../list_recent_by_accompanying_period.html.twig | 2 +- .../ChillPersonBundle/Resources/views/Entity/person.html.twig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/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 b60325bec..9bee504a9 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig @@ -43,7 +43,7 @@ {%- endif -%} {%- if options['addAgeBadge'] -%} {% if person.age is not null and person.deathDate is null %} - ({{- 'years_old'|trans({ 'age': person.age }) -}}) + ({{- 'years_old'|trans({ 'age': person.age }) -}}) {% endif %} {% endif %} {% endmacro raw %} From 4d1a553474e512ed0b9b9cff3a0dbced1ed0f177 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 28 Jan 2022 11:40:08 +0100 Subject: [PATCH 12/27] =?UTF-8?q?show=20activity=20attendee=20(pr=C3=A9sen?= =?UTF-8?q?ce)=20in=20the=20activity=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/views/Activity/_list_item.html.twig | 11 +++++++++++ .../Resources/views/Activity/show.html.twig | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig index 6b2e33dfb..fadf7ff14 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig @@ -41,6 +41,17 @@
    {% endif %} + {% if activity.attendee and t.attendeeVisible %} +
    +

    {{ 'Attendee'|trans }}

    +
    +

    + {{ activity.attendee.name|localize_translatable_string }} +

    +
    +
    + {% endif %} + {% if activity.sentReceived is not empty and t.sentReceivedVisible %}

    {{ 'Sent received'|trans }}

    diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig index 546ba99ce..a5e3bd1fd 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig @@ -165,11 +165,7 @@
    {{ 'Attendee'|trans }}
    {% if entity.attendee is not null %} - {% if entity.attendee %} - {{ 'present'|trans|capitalize }} - {% else %} - {{ 'not present'|trans|capitalize }} - {% endif %} + {{ entity.attendee.name|localize_translatable_string }} {% else %} {{ 'None'|trans|capitalize }} {% endif %} From 105fe16122711fb7f69917040a6c807a27968460 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 28 Jan 2022 11:40:30 +0100 Subject: [PATCH 13/27] upd CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f2fb4a22..3683260d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to ## Unreleased +* [activity] show activity attendee (présence) in the activity list (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/412) +* [activity] admin: change validation rule for social action visible field (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/413) * [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 From bc906644806a46066d4a244aa6ce5eed2e49403b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 29 Jan 2022 01:14:30 +0100 Subject: [PATCH 14/27] api endpoint for search household --- .../ChillMainBundle/Search/SearchApiQuery.php | 25 +++- .../ChillMainBundle/chill.api.specs.yaml | 2 + .../Search/SearchHouseholdApiProvider.php | 108 ++++++++++++++++++ .../config/services/search.yaml | 4 + 4 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php diff --git a/src/Bundle/ChillMainBundle/Search/SearchApiQuery.php b/src/Bundle/ChillMainBundle/Search/SearchApiQuery.php index 2fcea304d..57193a96d 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchApiQuery.php +++ b/src/Bundle/ChillMainBundle/Search/SearchApiQuery.php @@ -22,6 +22,10 @@ class SearchApiQuery private array $fromClauseParams = []; + private bool $isDistinct = false; + + private ?string $isDistinctKey = null; + private ?string $jsonbMetadata = null; private array $jsonbMetadataParams = []; @@ -105,6 +109,11 @@ class SearchApiQuery ]); } + public function getDistinct(): bool + { + return $this->isDistinct; + } + public function getFromClause(): string { return $this->fromClause; @@ -139,6 +148,14 @@ class SearchApiQuery return $this; } + public function setDistinct(bool $distinct, string $distinctKey): self + { + $this->isDistinct = $distinct; + $this->isDistinctKey = $distinctKey; + + return $this; + } + public function setFromClause(string $fromClause, array $params = []): self { $this->fromClause = $fromClause; @@ -185,7 +202,11 @@ class SearchApiQuery private function buildSelectClause(bool $countOnly = false): string { if ($countOnly) { - return 'count(*) AS c'; + if (!$this->isDistinct) { + return 'count(*) AS c'; + } + + return 'count(distinct ' . $this->isDistinctKey . ') AS c'; } $selects = $this->getSelectClauses(); @@ -202,7 +223,7 @@ class SearchApiQuery $selects[] = strtr('{pertinence} AS pertinence', ['{pertinence}' => $this->pertinence]); } - return implode(', ', $selects); + return ($this->isDistinct ? 'DISTINCT ' : '') . implode(', ', $selects); } private function buildSelectParams(bool $count = false): array diff --git a/src/Bundle/ChillMainBundle/chill.api.specs.yaml b/src/Bundle/ChillMainBundle/chill.api.specs.yaml index 4f2e3648e..034dfe74b 100644 --- a/src/Bundle/ChillMainBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillMainBundle/chill.api.specs.yaml @@ -134,6 +134,7 @@ paths: - search - person - thirdparty + - household description: > The search is performed across multiple entities. The entities must be listed into `type` parameters. @@ -159,6 +160,7 @@ paths: - person - thirdparty - user + - household responses: 200: description: "OK" diff --git a/src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php b/src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php new file mode 100644 index 000000000..bc2cf23f8 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php @@ -0,0 +1,108 @@ +householdRepository = $householdRepository; + $this->personACLAwareRepository = $personACLAwareRepository; + $this->security = $security; + $this->authorizationHelper = $authorizationHelper; + $this->extractDateFromPattern = $extractDateFromPattern; + $this->extractPhonenumberFromPattern = $extractPhonenumberFromPattern; + } + + public function getResult(string $key, array $metadata, float $pertinence) + { + return $this->householdRepository->find($metadata['id']); + } + + public function prepare(array $metadatas): void + { + $ids = array_map(static fn ($m) => $m['id'], $metadatas); + + $this->householdRepository->findBy(['id' => $ids]); + } + + public function provideQuery(string $pattern, array $parameters): SearchApiQuery + { + $datesResult = $this->extractDateFromPattern->extractDates($pattern); + $phoneResult = $this->extractPhonenumberFromPattern->extractPhonenumber($datesResult->getFilteredSubject()); + $filtered = $phoneResult->getFilteredSubject(); + + $query = $this->personACLAwareRepository->buildAuthorizedQuery( + $filtered, + null, + null, + count($datesResult->getFound()) > 0 ? $datesResult->getFound()[0] : null, + null, + null, + null, + null, + count($phoneResult->getFound()) > 0 ? $phoneResult->getFound()[0] : null + ); + + $query + ->setDistinct(true, 'household_id') + ->setFromClause( + 'view_chill_person_household_address AS vcpha ' . + 'JOIN chill_person_person AS person ON vcpha.person_id = person.id' + ) + ->setSelectKey('household') + ->setSelectJsonbMetadata("jsonb_build_object('id', vcpha.household_id)"); + + return $query; + } + + public function supportsResult(string $key, array $metadatas): bool + { + return 'household' === $key; + } + + public function supportsTypes(string $pattern, array $types, array $parameters): bool + { + return in_array('household', $types, true); + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/search.yaml b/src/Bundle/ChillPersonBundle/config/services/search.yaml index 5428c8105..d700eef19 100644 --- a/src/Bundle/ChillPersonBundle/config/services/search.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/search.yaml @@ -11,3 +11,7 @@ services: Chill\PersonBundle\Search\SearchPersonApiProvider: autowire: true autoconfigure: true + + Chill\PersonBundle\Search\SearchHouseholdApiProvider: + autowire: true + autoconfigure: true From d1a0934bb18157f08cdd2012607acc3de7dfe151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 29 Jan 2022 02:38:47 +0100 Subject: [PATCH 15/27] search household in household mmebers editor --- .../Resources/public/chill/scss/buttons.scss | 2 ++ .../public/vuejs/_components/BadgeEntity.vue | 8 ++++- .../components/Household.vue | 31 +++++++++++++++++++ .../public/vuejs/_components/AddPersons.vue | 12 +++---- .../AddPersons/PersonSuggestion.vue | 11 +++++-- .../_components/AddPersons/TypeHousehold.vue | 27 ++++++++++++++++ .../Search/SearchHouseholdApiProvider.php | 1 + 7 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeHousehold.vue diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/buttons.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/buttons.scss index 1eb437a2a..627f45be4 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/buttons.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/buttons.scss @@ -22,6 +22,7 @@ $chill-theme-buttons: ( "cancel": $gray-300, "choose": $gray-300, "notify": $gray-300, + "search": $gray-300, "unlink": $chill-red, "tpchild": $chill-pink, ); @@ -108,6 +109,7 @@ $chill-theme-buttons: ( &.btn-notify::before { content: "\f1d8"; } // fa-paper-plane &.btn-tpchild::before { content: "\f007"; } // fa-user &.btn-download::before { content: "\f019"; } // fa-download + &.btn-search::before { content: "\f002"; } // fa-search } diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/BadgeEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/BadgeEntity.vue index 5dd770328..4e99b7fd3 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/BadgeEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/BadgeEntity.vue @@ -24,6 +24,11 @@ {{ $t('user')}} + + {{ $t('household')}} + + + -