courseLocation: init Address context in the store

This commit is contained in:
Mathieu Jaumotte 2021-08-12 15:42:48 +02:00
parent 368bbcf9b2
commit 205c48f58a
4 changed files with 53 additions and 26 deletions

View File

@ -47,7 +47,8 @@ export default {
Confirm,
},
computed: mapState([
'accompanyingCourse'
'accompanyingCourse',
'addressContext'
])
};
</script>

View File

@ -27,8 +27,8 @@
<ul class="record_actions">
<li>
<add-address
v-bind:key="addAddress.type"
v-bind:context="context"
v-bind:key="addAddress.type"
v-bind:options="addAddress.options"
v-bind:result="addAddress.result"
ref="addAddress">
@ -41,6 +41,7 @@
</template>
<script>
import { mapState } from "vuex";
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress.vue';
export default {
@ -50,25 +51,21 @@ export default {
},
data() {
return {
context: {
edit: true, //dynamic //window.mode === 'edit',
personId: null, //window.personId,
addressId: null, //window.addressId,
backUrl: null //window.backUrl,
},
addAddress: {
options: {
/// Options override default.
/// null value take default component value
button: {
text: { create: null, edit: null },
type: null,
size: null,
//display: false
text: {
create: 'courselocation.add_temporary_address',
edit: 'courselocation.edit_temporary_address'
},
},
title: {
create: 'courselocation.add_temporary_address',
edit: 'courselocation.edit_temporary_address'
},
/// Modal title text if create or edit address (trans chain, see i18n)
title: { create: null, edit: null },
/// Display each step in page or Modal
bindModal: {
//step1: false, step2: false
@ -77,15 +74,39 @@ export default {
displayResult: true,
redirectToBackUrl: false
},
type: 'courseLocation',
type: 'accompanying_course_location',
result: null // <== returned from addAddress component
}
}
},
computed: {
...mapState({
accompanyingCourse: state => state.accompanyingCourse,
context: state => state.addressContext
})
},
methods: {
initAddressContext() {
let ac = {
entity: {
type: this.accompanyingCourse.type,
id: this.accompanyingCourse.id
},
edit: false,
addressId: null,
backUrl: null
}
this.$store.commit('setAddressContext', ac);
},
displayErrors() {
return this.$refs.addAddress.errorMsg;
}
},
mounted() {
this.initAddressContext();
console.log('ac.locationStatus', this.accompanyingCourse.locationStatus);
console.log('ac.location (temporary location)', this.accompanyingCourse.location);
console.log('ac.personLocation', this.accompanyingCourse.personLocation);
}
}
</script>

View File

@ -65,8 +65,8 @@ const appMessages = {
},
courselocation: {
title: "Localisation du parcours",
add_temp_address: "Ajouter une adresse temporaire",
edit_temp_address: "Modifier l'adresse temporaire",
add_temporary_address: "Ajouter une adresse temporaire",
edit_temporary_address: "Modifier l'adresse temporaire",
assign_course_address: "Désigner comme l'adresse du parcours",
},
referrer: {

View File

@ -20,6 +20,7 @@ let initPromise = getAccompanyingCourse(id)
},
state: {
accompanyingCourse: accompanying_course,
addressContext: {},
errorMsg: []
},
getters: {
@ -92,6 +93,10 @@ let initPromise = getAccompanyingCourse(id)
confirmAccompanyingCourse(state, response) {
//console.log('### mutation: confirmAccompanyingCourse: response', response);
state.accompanyingCourse.step = response.step;
},
setAddressContext(state, context) {
//console.log('define location context');
state.addressContext = context;
}
},
actions: {