Merge branch 'accourse_impr' into onTheFly

This commit is contained in:
Mathieu Jaumotte 2021-09-30 11:43:49 +02:00
commit 309fe40564
7 changed files with 131 additions and 34 deletions

View File

@ -87,8 +87,8 @@ export default {
}
padding: 0em 0em;
margin: 1em 0;
border: 1px dotted tint-color($chill-accourse-context, 10%);
border-radius: 5px;
border: 1px dotted tint-color($chill-accourse-context, 10%);
border-left: 1px dotted tint-color($chill-accourse-context, 10%);
border-right: 1px dotted tint-color($chill-accourse-context, 10%);
dd {
@ -96,10 +96,15 @@ export default {
}
& > div {
margin: 1em 3em 0;
&.flex-table,
&.flex-bloc {
margin: 1em 0 0;
}
&.alert.to-confirm {
margin: 1em 0 0;
padding: 1em 3em;
}
}
div.flex-table {

View File

@ -91,7 +91,7 @@ export default {
},
scopes: {
msg: 'confirm.set_a_scope',
anchor: '#section-65'
anchor: '#section-60'
}
}
}

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>
@ -37,9 +52,9 @@
<li>
<add-address
v-if="!isPersonLocation"
:key="key"
:context="context"
:key="addAddress.type"
:options="addAddress.options"
:options="options"
:addressChangedCallback="submitTemporaryAddress"
ref="addAddress">
</add-address>
@ -55,11 +70,15 @@
</ul>
</div>
<div v-if="!isLocationValid" class="alert alert-warning to-confirm">
{{ $t('courselocation.not_valid') }}
</div>
</div>
</template>
<script>
import { mapState } from "vuex";
import {mapGetters, mapState} from "vuex";
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress.vue';
import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue';
@ -72,10 +91,7 @@ export default {
data() {
return {
addAddress: {
type: 'accompanying_course_location',
options: {
/// Options override default.
/// null value take default component value
button: {
text: {
create: 'courselocation.add_temporary_address',
@ -86,12 +102,6 @@ export default {
create: 'courselocation.add_temporary_address',
edit: 'courselocation.edit_temporary_address'
},
/// Display each step in page or Modal
openPanesInModal: true,
// Use Date fields
//useDate: {
// validFrom: true
//},
hideAddress: true
}
}
@ -102,6 +112,16 @@ export default {
accompanyingCourse: state => state.accompanyingCourse,
context: state => state.addressContext
}),
...mapGetters([
'isLocationValid'
]),
options() {
return this.addAddress.options;
},
key() {
return (this.context.edit) ? 'address_' + this.context.addressId
: this.accompanyingCourse.type + '_' + this.accompanyingCourse.id ;
},
isTemporaryAddress() {
return this.accompanyingCourse.locationStatus === 'address';
},
@ -111,11 +131,40 @@ 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_.length > 0) ?
addressInParticipations_.reduce(booleanReducer) : false;
//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: {
@ -161,12 +210,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>
@ -58,11 +58,14 @@
</add-persons>
</div>
<div v-if="!isParticipationValid" class="alert alert-warning to-confirm">
{{ $t('persons_associated.participation_not_valid') }}
</div>
</div>
</template>
<script>
import { mapState } from 'vuex';
import {mapGetters, mapState} from 'vuex';
import ParticipationItem from "./PersonsAssociated/ParticipationItem.vue"
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue'
@ -89,6 +92,9 @@ export default {
courseId: state => state.accompanyingCourse.id,
participations: state => state.accompanyingCourse.participations
}),
...mapGetters([
'isParticipationValid'
]),
currentParticipations() {
return this.participations.filter(p => p.endDate === null)
},
@ -126,7 +132,7 @@ export default {
<style lang="scss" scoped>
div#accompanying-course {
div.vue-component {
& > div.alert {
& > div.alert.no-household {
margin: 0 0 -1em;
}
div.no-household {

View File

@ -1,18 +1,20 @@
<template>
<div class="vue-component">
<h2><a id="section-60"></a>{{ $t('scopes.title') }}</h2>
<h2><a id="section-60"></a>{{ $t('scopes.title') }}</h2>
<ul>
<li v-for="s in scopes">
<input type="checkbox" v-model="checkedScopes" :value="s" />
{{ s.name.fr }}
</li>
</ul>
<div class="mb-4">
<div class="form-check" v-for="s in scopes">
<input class="form-check-input" type="checkbox" v-model="checkedScopes" :value="s" />
<label class="form-check-label">
{{ s.name.fr }}
</label>
</div>
</div>
<div v-if="!isScopeValid" class="alert alert-warning separator">
<div v-if="!isScopeValid" class="alert alert-warning to-confirm">
{{ $t('scopes.add_at_least_one') }}
</div>
</div>
</template>

View File

@ -21,13 +21,17 @@
</VueMultiselect>
</div>
<div v-if="!isSocialIssueValid" class="alert alert-warning to-confirm">
{{ $t('social_issue.not_valid') }}
</div>
</div>
</template>
<script>
import VueMultiselect from 'vue-multiselect';
import { getSocialIssues } from '../api';
import { mapState } from 'vuex';
import {mapGetters, mapState} from 'vuex';
export default {
name: "SocialIssue",
@ -41,6 +45,9 @@ export default {
...mapState({
value: state => state.accompanyingCourse.socialIssues,
}),
...mapGetters([
'isSocialIssueValid'
])
},
mounted() {
this.getOptions();

View File

@ -51,6 +51,7 @@ const appMessages = {
show_household: "Voir le ménage",
person_without_household_warning: "Certaines personnes n'appartiennent à aucun ménage actuellement. Renseignez leur appartenance à un ménage dès que possible.",
update_household: "Modifier l'appartenance",
participation_not_valid: "Sélectionnez ou créez au minimum 1 usager",
},
requestor: {
title: "Demandeur",
@ -73,6 +74,7 @@ const appMessages = {
social_issue: {
title: "Problématiques sociales",
label: "Choisir les problématiques sociales",
not_valid: "Sélectionnez au minimum une problématique sociale",
},
courselocation: {
title: "Localisation du parcours",
@ -80,11 +82,13 @@ 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",
person_locator: "Parcours localisé auprès de {0}",
not_valid: "Indiquez au minimum une localisation temporaire du parcours",
no_address: "Il n'y a pas d'adresse associée au parcours"
},
scopes: {