mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
CourseLocation: action and mutation for updateLocation, hide button if personLocation
This commit is contained in:
@@ -27,10 +27,12 @@
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<add-address
|
||||
v-if="hasTemporaryAddressButton"
|
||||
v-bind:context="context"
|
||||
v-bind:key="addAddress.type"
|
||||
v-bind:options="addAddress.options"
|
||||
v-bind:result="addAddress.result"
|
||||
@submitAddress="submitAddress"
|
||||
ref="addAddress">
|
||||
</add-address>
|
||||
</li>
|
||||
@@ -52,8 +54,8 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
addAddress: {
|
||||
type: 'accompanying_course_location',
|
||||
options: {
|
||||
|
||||
/// Options override default.
|
||||
/// null value take default component value
|
||||
button: {
|
||||
@@ -69,13 +71,8 @@ export default {
|
||||
/// Display each step in page or Modal
|
||||
bindModal: {
|
||||
//step1: false, step2: false
|
||||
},
|
||||
// Options only for root parent component
|
||||
displayResult: true,
|
||||
redirectToBackUrl: false
|
||||
},
|
||||
type: 'accompanying_course_location',
|
||||
result: null // <== returned from addAddress component
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -83,27 +80,43 @@ export default {
|
||||
...mapState({
|
||||
accompanyingCourse: state => state.accompanyingCourse,
|
||||
context: state => state.addressContext
|
||||
})
|
||||
}),
|
||||
hasTemporaryAddressButton() { // return true if locationStatus equal 'none' or 'address'
|
||||
return this.accompanyingCourse.locationStatus !== 'person';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initAddressContext() {
|
||||
let ac = {
|
||||
let context = {
|
||||
entity: {
|
||||
type: this.accompanyingCourse.type,
|
||||
id: this.accompanyingCourse.id
|
||||
},
|
||||
edit: false,
|
||||
addressId: null,
|
||||
backUrl: null
|
||||
addressId: null
|
||||
}
|
||||
this.$store.commit('setAddressContext', ac);
|
||||
if (this.accompanyingCourse.location) {
|
||||
context['edit'] = true;
|
||||
context['addressId'] = this.accompanyingCourse.location.address_id
|
||||
}
|
||||
this.$store.commit('setAddressContext', context);
|
||||
},
|
||||
displayErrors() {
|
||||
return this.$refs.addAddress.errorMsg;
|
||||
},
|
||||
submitAddress() {
|
||||
console.log('@@@ click on Submit Address Button');
|
||||
|
||||
let payload = this.$refs.addAddress.submitNewAddress();
|
||||
console.log('payload from parent', payload);
|
||||
|
||||
this.$store.dispatch('updateLocation', payload);
|
||||
|
||||
}
|
||||
},
|
||||
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);
|
||||
|
Reference in New Issue
Block a user