CourseLocation: replace in accourse vue component the old resume _warning_address.html.twig message

This commit is contained in:
Mathieu Jaumotte 2021-09-27 13:03:17 +02:00
parent 82db55cfec
commit eb89fa2cd4
3 changed files with 72 additions and 8 deletions

View File

@ -14,6 +14,18 @@
</label>
</div>
<div v-if="hasNoPersonLocation" class="alert alert-danger no-person-location">
<i class="fa fa-warning fa-2x"></i>
<div>
<p>
{{ $t('courselocation.associate_at_least_one_person_with_one_household_with_address') }}
<a href="#section-10">
<i class="fa fa-level-up fa-fw"></i>
</a>
</p>
</div>
</div>
<div class="flex-table" v-if="accompanyingCourse.location">
<div class="item-bloc">
<address-render-box
@ -27,7 +39,10 @@
</div>
<div v-if="isTemporaryAddress" class="alert alert-warning separator">
<p>{{ $t('courselocation.temporary_address_must_be_changed') }}</p>
<p>
{{ $t('courselocation.temporary_address_must_be_changed') }}
<i class="fa fa-fw fa-map-marker"></i>
</p>
</div>
</div>
</div>
@ -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 {
</script>
<style lang="scss" scoped>
div.flex-table {
div.item-bloc {
div.alert {
margin: 0 -0.9em -1em;
div#accompanying-course {
div.vue-component {
& > div.alert.no-person-location {
margin: 0 0 -1em;
}
div.no-person-location {
padding-bottom: 1.5em;
display: flex;
flex-direction: row;
& > i {
flex-basis: 1.5em; flex-grow: 0; flex-shrink: 0;
padding-top: 0.2em;
opacity: 0.75;
}
& > div {
flex-basis: auto;
div.action {
button.btn-update {
margin-right: 2em;
}
}
}
}
div.flex-table {
div.item-bloc {
div.alert {
margin: 0 -0.9em -1em;
}
}
}
}
}
</style>

View File

@ -26,7 +26,7 @@
:id="p.person.id"
:value="p.person.id"
/>
<label class="form-check-label" for="hasNoHousehold">
<label class="form-check-label">
{{ p.person.text }}
</label>
</div>

View File

@ -81,7 +81,8 @@ const appMessages = {
edit_temporary_address: "Modifier l'adresse temporaire",
assign_course_address: "Désigner comme l'adresse du parcours",
remove_button: "Enlever l'adresse",
temporary_address_must_be_changed: "Cette adresse est temporaire et devrait être remplacée par celle d'un usager de référence.",
temporary_address_must_be_changed: "Cette adresse est temporaire. Le parcours devrait être localisé auprès d'un usager concerné.",
associate_at_least_one_person_with_one_household_with_address: "Associez au moins un membre du parcours à un ménage, et indiquez une adresse à ce ménage.",
sure: "Êtes-vous sûr ?",
sure_description: "Voulez-vous faire de cette adresse l'adresse du parcours ?",
ok: "Désigner comme adresse du parcours",