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() {
// TODO
//return addressSuggestions.length > 0
return true;
return false;
},
displaySuggestions() {
return !this.context.edit && this.hasSuggestions;
@ -325,7 +325,7 @@ export default {
return !this.context.edit && !this.inModal;
},
forceRedirect() {
return this.context.backUrl !== null;
return (!(this.context.backUrl === null || typeof this.context.backUrl === 'undefined'));
}
},
mounted() {
@ -339,7 +339,7 @@ export default {
console.log('Mounted now !');
if (this.context.edit) {
console.log('getInitialAddress');
console.log('getInitialAddress', this.context.addressId);
this.getInitialAddress(this.context.addressId);
}
this.openShowPane();
@ -380,15 +380,8 @@ export default {
console.log('displaySuggestions');
this.openSuggestPane();
} 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.getCountries(); // will open edit pane when resolve promise
this.getCountries(); // will open editPane when resolve promise
}
},
closeEditPane() {
@ -463,6 +456,13 @@ export default {
fetchCountries().then(
countries => new Promise((resolve, reject) => {
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.loading = false;
resolve()

View File

@ -1,4 +1,4 @@
<template>step3
<template>
<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>
@ -106,7 +106,3 @@ export default {
}
}
</script>
<style scoped>
</style>

View File

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

View File

@ -1,24 +1,28 @@
<template>
<div class="loading">
<i v-if="flag.loading" class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i>
<span class="sr-only">{{ $t('loading') }}</span>
</div>
<div v-if="errorMsg && errorMsg.length > 0" class="alert alert-danger">
{{ 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="!hideAddress">
<div class="loading">
<i v-if="flag.loading" class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i>
<span class="sr-only">{{ $t('loading') }}</span>
</div>
<div v-if="noAddressWithStickyActions" class="mt-5">
<p class="chill-no-data-statement">
{{ $t('not_yet_address') }}
</p>
</div>
<div v-if="errorMsg && errorMsg.length > 0" class="alert alert-danger">
{{ errorMsg }}
</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
:options="this.options"
@ -86,7 +90,7 @@ export default {
this.options.hideAddress : this.defaultz.hideAddress;
},
forceRedirect() {
return this.context.backUrl !== null;
return (!(this.context.backUrl === null || typeof this.context.backUrl === 'undefined'));
},
noAddressWithStickyActions() {
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">
<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"
:key="addAddress.type"
:options="addAddress.options"
:result="addAddress.result"
:addressChanged="submitTemporaryAddress"
:addressChangedCallback="submitTemporaryAddress"
ref="addAddress">
</add-address>
</li>
@ -133,30 +132,30 @@ export default {
this.$store.commit('setAddressContext', context);
},
removeAddress() {
//console.log('remove address');
let payload = {
target: this.context.target.name,
targetId: this.context.target.id,
locationStatusTo: 'none'
};
//console.log('remove address');
this.$store.dispatch('updateLocation', payload);
},
displayErrors() {
return this.$refs.addAddress.errorMsg;
},
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
this.$store.dispatch('updateLocation', payload);
this.$store.commit('setEditContextTrue');
this.$store.commit('setEditContextTrue', payload);
}
},
mounted() {
created() {
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);
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

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

View File

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