From eb89fa2cd47c3cbb0b62fda17ca135bcf2d39199 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 27 Sep 2021 13:03:17 +0200 Subject: [PATCH] CourseLocation: replace in accourse vue component the old resume _warning_address.html.twig message --- .../components/CourseLocation.vue | 75 +++++++++++++++++-- .../components/PersonsAssociated.vue | 2 +- .../vuejs/AccompanyingCourse/js/i18n.js | 3 +- 3 files changed, 72 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue index b422ba23d..3e6b40c28 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue @@ -14,6 +14,18 @@ +
+ +
+

+ {{ $t('courselocation.associate_at_least_one_person_with_one_household_with_address') }} + + + +

+
+
+
-

{{ $t('courselocation.temporary_address_must_be_changed') }}

+

+ {{ $t('courselocation.temporary_address_must_be_changed') }} + +

@@ -116,11 +131,35 @@ export default { hasNoLocation() { return this.accompanyingCourse.locationStatus === 'none'; }, + currentParticipations() { + return this.accompanyingCourse.participations.filter(p => p.enddate !== null); + }, + hasNoPersonLocation() { + let addressInParticipations_ = [] + this.currentParticipations.forEach(p => { + addressInParticipations_.push(this.checkHouseholdAddressForParticipation(p)); + }); + const booleanReducer = (previousValue, currentValue) => previousValue || currentValue; + let addressInParticipations = addressInParticipations_.reduce(booleanReducer); + //console.log(addressInParticipations_, addressInParticipations); + return ( + this.accompanyingCourse.step !== 'DRAFT' + && this.isTemporaryAddress + && !addressInParticipations + ) + ; + }, isContextEdit() { return this.context.edit; } }, methods: { + checkHouseholdAddressForParticipation(participation) { + if (participation.person.current_household_id === null) { + return false; + } + return participation.person.current_household_address !== null; + }, initAddressContext() { let context = { target: { @@ -166,12 +205,36 @@ export default { 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 97a286d70..52b538284 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue @@ -26,7 +26,7 @@ :id="p.person.id" :value="p.person.id" /> -