From 21274155b5635a152593cb4d2d785c7c74d380dc Mon Sep 17 00:00:00 2001 From: LenaertsJ Date: Thu, 23 Jan 2025 20:19:31 +0000 Subject: [PATCH] Display first associated persons in the banner of an accompanying course --- .../unreleased/Feature-20250123-211322.yaml | 6 + .../AccompanyingCourse/components/Banner.vue | 12 +- .../components/Banner/PersonsAssociated.vue | 113 +++++++++++------- .../vuejs/AccompanyingCourse/js/i18n.js | 1 + .../views/AccompanyingCourse/banner.html.twig | 23 ++-- 5 files changed, 105 insertions(+), 50 deletions(-) create mode 100644 .changes/unreleased/Feature-20250123-211322.yaml diff --git a/.changes/unreleased/Feature-20250123-211322.yaml b/.changes/unreleased/Feature-20250123-211322.yaml new file mode 100644 index 000000000..45793623f --- /dev/null +++ b/.changes/unreleased/Feature-20250123-211322.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: Show the first 3 persons directly in the accompanying period's banner +time: 2025-01-23T21:13:22.926870961+01:00 +custom: + Issue: "320" + SchemaChange: No schema change diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue index dec68cd1f..097b746b1 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue @@ -80,6 +80,13 @@ + + + + - + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/PersonsAssociated.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/PersonsAssociated.vue index 9a957b74e..c578402b3 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/PersonsAssociated.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/PersonsAssociated.vue @@ -1,26 +1,45 @@ @@ -33,7 +52,14 @@ export default { components: { OnTheFly, }, - props: ["accompanyingCourse"], + props: ["accompanyingCourse", "shortlist"], + data() { + return { + showAllPersons: false, + maxTotalPersons: 2, + nbShortList: 3, + }; + }, computed: { participations() { return this.accompanyingCourse.participations.filter( @@ -43,36 +69,37 @@ export default { persons() { return this.participations.map((p) => p.person); }, + firstPersons() { + return this.participations.slice(0, 3).map((p) => p.person); + }, + hasMoreThanShortListPerson() { + return this.participations.length > 3; + }, + countMoreThanShortListPerson() { + return this.participations.length - 3; + }, resources() { return this.accompanyingCourse.resources; }, requestor() { return this.accompanyingCourse.requestor; }, + personsByHousehold() { + const households = new Map(); + this.accompanyingCourse.participations + .filter((p) => p.endDate === null) + .map((p) => p.person) + .forEach((person) => { + if (!households.has(person.current_household_id || -1)) { + households.set(person.current_household_id || -1, []); + } + households.get(person.current_household_id || -1).push(person); + }); + + return households; + }, }, methods: { - uniq(array) { - return [...new Set(array)]; - }, - personsByHousehold() { - let households = []; - this.persons.forEach((p) => { - households.push(p.current_household_id); - }); - - let personsByHousehold = []; - this.uniq(households).forEach((h) => { - personsByHousehold.push({ - id: h !== null ? h : 0, - persons: this.persons.filter((p) => p.current_household_id === h), - }); - }); - //console.log(personsByHousehold) - return personsByHousehold; - }, - householdExists(id) { - return id !== 0; - }, householdLink(id) { return `/fr/person/household/${id}/summary`; }, @@ -81,6 +108,10 @@ export default {