Merge branch 'improve_address' into person_renderbox_thirdparty_onthefly

This commit is contained in:
Mathieu Jaumotte 2021-09-22 20:32:28 +02:00
commit 14fdeac4fd
8 changed files with 56 additions and 53 deletions

View File

@ -306,7 +306,7 @@ export default {
hasSuggestions() { hasSuggestions() {
// TODO // TODO
//return addressSuggestions.length > 0 //return addressSuggestions.length > 0
return true; return false;
}, },
displaySuggestions() { displaySuggestions() {
return !this.context.edit && this.hasSuggestions; return !this.context.edit && this.hasSuggestions;
@ -325,7 +325,7 @@ export default {
return !this.context.edit && !this.inModal; return !this.context.edit && !this.inModal;
}, },
forceRedirect() { forceRedirect() {
return this.context.backUrl !== null; return (!(this.context.backUrl === null || typeof this.context.backUrl === 'undefined'));
} }
}, },
mounted() { mounted() {
@ -339,7 +339,7 @@ export default {
console.log('Mounted now !'); console.log('Mounted now !');
if (this.context.edit) { if (this.context.edit) {
console.log('getInitialAddress'); console.log('getInitialAddress', this.context.addressId);
this.getInitialAddress(this.context.addressId); this.getInitialAddress(this.context.addressId);
} }
this.openShowPane(); this.openShowPane();
@ -380,15 +380,8 @@ export default {
console.log('displaySuggestions'); console.log('displaySuggestions');
this.openSuggestPane(); this.openSuggestPane();
} else { } else {
if (this.flag.suggestPane === true) {
this.closeSuggestPane();
}
if (this.flag.showPane === true) {
this.closeShowPane();
}
console.log('step2: open the Edit panel');
this.initForm(); this.initForm();
this.getCountries(); // will open edit pane when resolve promise this.getCountries(); // will open editPane when resolve promise
} }
}, },
closeEditPane() { closeEditPane() {
@ -463,6 +456,13 @@ export default {
fetchCountries().then( fetchCountries().then(
countries => new Promise((resolve, reject) => { countries => new Promise((resolve, reject) => {
this.entity.loaded.countries = countries.results; this.entity.loaded.countries = countries.results;
if (this.flag.suggestPane === true) {
this.closeSuggestPane();
}
if (this.flag.showPane === true) {
this.closeShowPane();
}
console.log('step2: open the Edit panel');
this.flag.editPane = true; this.flag.editPane = true;
this.flag.loading = false; this.flag.loading = false;
resolve() resolve()

View File

@ -1,4 +1,4 @@
<template>step3 <template>
<div v-if="insideModal === false" class="loading"> <div v-if="insideModal === false" class="loading">
<i v-if="flag.loading" class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i> <i v-if="flag.loading" class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i>
@ -106,7 +106,3 @@ export default {
} }
} }
</script> </script>
<style scoped>
</style>

View File

@ -1,4 +1,4 @@
<template>step2 <template>
<div class="address-form"> <div class="address-form">
<!-- Not display in modal --> <!-- Not display in modal -->

View File

@ -1,24 +1,28 @@
<template> <template>
<div class="loading"> <div v-if="!hideAddress">
<i v-if="flag.loading" class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i> <div class="loading">
<span class="sr-only">{{ $t('loading') }}</span> <i v-if="flag.loading" class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i>
</div> <span class="sr-only">{{ $t('loading') }}</span>
<div v-if="errorMsg && errorMsg.length > 0" class="alert alert-danger"> </div>
{{ errorMsg }}
</div>
<div v-if="flag.success" class="alert alert-success">
{{ $t(getSuccessText) }}
<span v-if="forceRedirect">{{ $t('wait_redirection') }}</span>
</div>
<div v-if="noAddressWithStickyActions" class="mt-5"> <div v-if="errorMsg && errorMsg.length > 0" class="alert alert-danger">
<p class="chill-no-data-statement"> {{ errorMsg }}
{{ $t('not_yet_address') }} </div>
</p>
</div>
<address-render-box v-if="!hideAddress" :address="address"></address-render-box> <div v-if="flag.success" class="alert alert-success">
{{ $t(getSuccessText) }}
<span v-if="forceRedirect">{{ $t('wait_redirection') }}</span>
</div>
<div v-if="noAddressWithStickyActions" class="mt-5">
<p class="chill-no-data-statement">
{{ $t('not_yet_address') }}
</p>
</div>
<address-render-box :address="address"></address-render-box>
</div>
<action-buttons <action-buttons
:options="this.options" :options="this.options"
@ -86,7 +90,7 @@ export default {
this.options.hideAddress : this.defaultz.hideAddress; this.options.hideAddress : this.defaultz.hideAddress;
}, },
forceRedirect() { forceRedirect() {
return this.context.backUrl !== null; return (!(this.context.backUrl === null || typeof this.context.backUrl === 'undefined'));
}, },
noAddressWithStickyActions() { noAddressWithStickyActions() {
return !this.context.edit && !this.address.id && this.options.stickyActions; return !this.context.edit && !this.address.id && this.options.stickyActions;

View File

@ -1,4 +1,4 @@
<template>step1 <template>
<div v-if="insideModal === false" class="loading"> <div v-if="insideModal === false" class="loading">
<i v-if="flag.loading" class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i> <i v-if="flag.loading" class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i>

View File

@ -40,8 +40,7 @@
:context="context" :context="context"
:key="addAddress.type" :key="addAddress.type"
:options="addAddress.options" :options="addAddress.options"
:result="addAddress.result" :addressChangedCallback="submitTemporaryAddress"
:addressChanged="submitTemporaryAddress"
ref="addAddress"> ref="addAddress">
</add-address> </add-address>
</li> </li>
@ -133,30 +132,30 @@ export default {
this.$store.commit('setAddressContext', context); this.$store.commit('setAddressContext', context);
}, },
removeAddress() { removeAddress() {
//console.log('remove address');
let payload = { let payload = {
target: this.context.target.name, target: this.context.target.name,
targetId: this.context.target.id, targetId: this.context.target.id,
locationStatusTo: 'none' locationStatusTo: 'none'
}; };
//console.log('remove address');
this.$store.dispatch('updateLocation', payload); this.$store.dispatch('updateLocation', payload);
}, },
displayErrors() { displayErrors() {
return this.$refs.addAddress.errorMsg; return this.$refs.addAddress.errorMsg;
}, },
submitTemporaryAddress(payload) { submitTemporaryAddress(payload) {
//console.log('@@@ click on Submit Temporary Address Button'); //console.log('@@@ click on Submit Temporary Address Button', payload);
payload['locationStatusTo'] = 'address'; // <== temporary, not none, not person payload['locationStatusTo'] = 'address'; // <== temporary, not none, not person
this.$store.dispatch('updateLocation', payload); this.$store.dispatch('updateLocation', payload);
this.$store.commit('setEditContextTrue'); this.$store.commit('setEditContextTrue', payload);
} }
}, },
mounted() { created() {
this.initAddressContext(); this.initAddressContext();
//console.log('ac.locationStatus', this.accompanyingCourse.locationStatus); console.log('ac.locationStatus', this.accompanyingCourse.locationStatus);
//console.log('ac.location (temporary location)', this.accompanyingCourse.location); console.log('ac.location (temporary location)', this.accompanyingCourse.location);
//console.log('ac.personLocation', this.accompanyingCourse.personLocation); console.log('ac.personLocation', this.accompanyingCourse.personLocation);
} }
} }
</script> </script>

View File

@ -129,14 +129,19 @@ let initPromise = getAccompanyingCourse(id)
state.addressContext = context; state.addressContext = context;
}, },
updateLocation(state, r) { updateLocation(state, r) {
//console.log('### mutation: set location attributes', r); //console.log('### mutation: set location attributes', r);
state.accompanyingCourse.location = r.location;
state.accompanyingCourse.locationStatus = r.locationStatus; state.accompanyingCourse.locationStatus = r.locationStatus;
if (r.locationStatus !== 'person') {
state.addressContext.addressId = r.location.address_id;
//console.log('mutation: update context addressId', state.addressContext.addressId);
}
state.accompanyingCourse.location = r.location;
state.accompanyingCourse.personLocation = r.personLocation; state.accompanyingCourse.personLocation = r.personLocation;
}, },
setEditContextTrue(state) { setEditContextTrue(state, payload) {
//console.log('### mutation: set edit context = true'); //console.log('### mutation: set edit context true with addressId', payload.addressId);
state.addressContext.edit = true; state.addressContext.edit = true;
state.addressContext.addressId = payload.addressId;
} }
}, },
actions: { actions: {
@ -260,7 +265,7 @@ let initPromise = getAccompanyingCourse(id)
})).catch((error) => { commit('catchError', error) }); })).catch((error) => { commit('catchError', error) });
}, },
updateLocation({ commit }, payload) { updateLocation({ commit }, payload) {
//console.log('## action: updateLocation', payload.locationStatusTo); //console.log('## action: updateLocation', payload.locationStatusTo);
let body = { 'type': payload.target, 'id': payload.targetId }; let body = { 'type': payload.target, 'id': payload.targetId };
let location = {}; let location = {};
if (payload.locationStatusTo === 'person') { // patch for person address (don't remove addressLocation) if (payload.locationStatusTo === 'person') { // patch for person address (don't remove addressLocation)

View File

@ -75,7 +75,7 @@
:key="addAddress.key" :key="addAddress.key"
:options="addAddress.options" :options="addAddress.options"
:result="addAddress.result" :result="addAddress.result"
@submitAddress="setHouseholdCreatedAddress" @addressChangedCallback="setHouseholdCreatedAddress"
ref="addAddress"> ref="addAddress">
</add-address> </add-address>
</li> </li>
@ -282,8 +282,7 @@ export default {
console.log('setHouseholdAddress', a); console.log('setHouseholdAddress', a);
this.$store.commit('setHouseholdAddress', a); this.$store.commit('setHouseholdAddress', a);
}, },
setHouseholdCreatedAddress() { setHouseholdCreatedAddress(payload) {
let payload = this.$refs.addAddress.submitNewAddress();
console.log('setHouseholdAddress', payload); console.log('setHouseholdAddress', payload);
this.$store.dispatch('setHouseholdNewAddress', payload); this.$store.dispatch('setHouseholdNewAddress', payload);
}, },