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

View File

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

View File

@ -14,6 +14,18 @@
</label> </label>
</div> </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="flex-table" v-if="accompanyingCourse.location">
<div class="item-bloc"> <div class="item-bloc">
<address-render-box <address-render-box
@ -27,7 +39,10 @@
</div> </div>
<div v-if="isTemporaryAddress" class="alert alert-warning separator"> <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> </div>
</div> </div>
@ -37,9 +52,9 @@
<li> <li>
<add-address <add-address
v-if="!isPersonLocation" v-if="!isPersonLocation"
:key="key"
:context="context" :context="context"
:key="addAddress.type" :options="options"
:options="addAddress.options"
:addressChangedCallback="submitTemporaryAddress" :addressChangedCallback="submitTemporaryAddress"
ref="addAddress"> ref="addAddress">
</add-address> </add-address>
@ -55,11 +70,15 @@
</ul> </ul>
</div> </div>
<div v-if="!isLocationValid" class="alert alert-warning to-confirm">
{{ $t('courselocation.not_valid') }}
</div>
</div> </div>
</template> </template>
<script> <script>
import { mapState } from "vuex"; import {mapGetters, mapState} from "vuex";
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress.vue'; import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress.vue';
import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue'; import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue';
@ -72,10 +91,7 @@ export default {
data() { data() {
return { return {
addAddress: { addAddress: {
type: 'accompanying_course_location',
options: { options: {
/// Options override default.
/// null value take default component value
button: { button: {
text: { text: {
create: 'courselocation.add_temporary_address', create: 'courselocation.add_temporary_address',
@ -86,12 +102,6 @@ export default {
create: 'courselocation.add_temporary_address', create: 'courselocation.add_temporary_address',
edit: 'courselocation.edit_temporary_address' edit: 'courselocation.edit_temporary_address'
}, },
/// Display each step in page or Modal
openPanesInModal: true,
// Use Date fields
//useDate: {
// validFrom: true
//},
hideAddress: true hideAddress: true
} }
} }
@ -102,6 +112,16 @@ export default {
accompanyingCourse: state => state.accompanyingCourse, accompanyingCourse: state => state.accompanyingCourse,
context: state => state.addressContext 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() { isTemporaryAddress() {
return this.accompanyingCourse.locationStatus === 'address'; return this.accompanyingCourse.locationStatus === 'address';
}, },
@ -111,11 +131,40 @@ export default {
hasNoLocation() { hasNoLocation() {
return this.accompanyingCourse.locationStatus === 'none'; 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() { isContextEdit() {
return this.context.edit; return this.context.edit;
} }
}, },
methods: { methods: {
checkHouseholdAddressForParticipation(participation) {
if (participation.person.current_household_id === null) {
return false;
}
return participation.person.current_household_address !== null;
},
initAddressContext() { initAddressContext() {
let context = { let context = {
target: { target: {
@ -161,6 +210,29 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
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.flex-table {
div.item-bloc { div.item-bloc {
div.alert { div.alert {
@ -168,5 +240,6 @@ div.flex-table {
} }
} }
} }
}
}
</style> </style>

View File

@ -26,7 +26,7 @@
:id="p.person.id" :id="p.person.id"
:value="p.person.id" :value="p.person.id"
/> />
<label class="form-check-label" for="hasNoHousehold"> <label class="form-check-label">
{{ p.person.text }} {{ p.person.text }}
</label> </label>
</div> </div>
@ -58,11 +58,14 @@
</add-persons> </add-persons>
</div> </div>
<div v-if="!isParticipationValid" class="alert alert-warning to-confirm">
{{ $t('persons_associated.participation_not_valid') }}
</div>
</div> </div>
</template> </template>
<script> <script>
import { mapState } from 'vuex'; import {mapGetters, mapState} from 'vuex';
import ParticipationItem from "./PersonsAssociated/ParticipationItem.vue" import ParticipationItem from "./PersonsAssociated/ParticipationItem.vue"
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue' import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue'
@ -89,6 +92,9 @@ export default {
courseId: state => state.accompanyingCourse.id, courseId: state => state.accompanyingCourse.id,
participations: state => state.accompanyingCourse.participations participations: state => state.accompanyingCourse.participations
}), }),
...mapGetters([
'isParticipationValid'
]),
currentParticipations() { currentParticipations() {
return this.participations.filter(p => p.endDate === null) return this.participations.filter(p => p.endDate === null)
}, },
@ -126,7 +132,7 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
div#accompanying-course { div#accompanying-course {
div.vue-component { div.vue-component {
& > div.alert { & > div.alert.no-household {
margin: 0 0 -1em; margin: 0 0 -1em;
} }
div.no-household { div.no-household {

View File

@ -2,18 +2,20 @@
<div class="vue-component"> <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> <div class="mb-4">
<li v-for="s in scopes"> <div class="form-check" v-for="s in scopes">
<input type="checkbox" v-model="checkedScopes" :value="s" /> <input class="form-check-input" type="checkbox" v-model="checkedScopes" :value="s" />
<label class="form-check-label">
{{ s.name.fr }} {{ s.name.fr }}
</li> </label>
</ul>
<div v-if="!isScopeValid" class="alert alert-warning separator">
{{ $t('scopes.add_at_least_one') }}
</div> </div>
</div> </div>
<div v-if="!isScopeValid" class="alert alert-warning to-confirm">
{{ $t('scopes.add_at_least_one') }}
</div>
</div>
</template> </template>
<script> <script>

View File

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

View File

@ -51,6 +51,7 @@ const appMessages = {
show_household: "Voir le ménage", 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.", 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", update_household: "Modifier l'appartenance",
participation_not_valid: "Sélectionnez ou créez au minimum 1 usager",
}, },
requestor: { requestor: {
title: "Demandeur", title: "Demandeur",
@ -73,6 +74,7 @@ const appMessages = {
social_issue: { social_issue: {
title: "Problématiques sociales", title: "Problématiques sociales",
label: "Choisir les problématiques sociales", label: "Choisir les problématiques sociales",
not_valid: "Sélectionnez au minimum une problématique sociale",
}, },
courselocation: { courselocation: {
title: "Localisation du parcours", title: "Localisation du parcours",
@ -80,11 +82,13 @@ const appMessages = {
edit_temporary_address: "Modifier l'adresse temporaire", edit_temporary_address: "Modifier l'adresse temporaire",
assign_course_address: "Désigner comme l'adresse du parcours", assign_course_address: "Désigner comme l'adresse du parcours",
remove_button: "Enlever l'adresse", 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: "Êtes-vous sûr ?",
sure_description: "Voulez-vous faire de cette adresse l'adresse du parcours ?", sure_description: "Voulez-vous faire de cette adresse l'adresse du parcours ?",
ok: "Désigner comme adresse du parcours", ok: "Désigner comme adresse du parcours",
person_locator: "Parcours localisé auprès de {0}", 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" no_address: "Il n'y a pas d'adresse associée au parcours"
}, },
scopes: { scopes: {