Merge branch 'improve_address' into person_renderbox_thirdparty_onthefly

This commit is contained in:
2021-09-23 13:46:54 +02:00
8 changed files with 112 additions and 49 deletions

View File

@@ -7,6 +7,7 @@
v-bind:defaultz="this.defaultz"
v-bind:entity="this.entity"
v-bind:flag="this.flag"
v-bind:useDatePane="this.useDatePane"
@openEditPane="openEditPane"
ref="showAddress">
</show-pane>
@@ -101,10 +102,8 @@
</template>
<template v-slot:footer>
<button class="btn btn-cancel change-icon" @click="resetPane">
{{ $t('action.cancel') }}
</button>
<button v-if="useDatePane" class="btn btn-misc" @click="closeEditPane">
<!--<button class="btn btn-cancel change-icon" @click="resetPane">{{ $t('action.cancel') }}</button>-->
<button v-if="!this.context.edit && this.useDatePane" class="btn btn-update change-icon" @click="closeEditPane">
{{ $t('nav.next')}}
<i class="fa fa-fw fa-arrow-right"></i>
</button>
@@ -132,8 +131,8 @@
</a>
</template>
<template v-slot:action>
<li v-if="useDatePane">
<button class="btn btn-misc" @click="closeEditPane">
<li v-if="!this.context.edit && this.useDatePane">
<button class="btn btn-update change-icon" @click="closeEditPane">
{{ $t('nav.next')}}
<i class="fa fa-fw fa-arrow-right"></i>
</button>
@@ -175,14 +174,14 @@
</template>
<template v-slot:footer>
<button class="btn btn-update" @click="openEditPane">
{{ $t('action.edit')}}
<button class="btn btn-misc" @click="openEditPane">
<i class="fa fa-fw fa-arrow-left"></i>
{{ $t('nav.previous')}}
</button>
<!--
<button class="btn btn-save">
<button class="btn btn-save" @click="closeDatePane">
{{ $t('action.save')}}
</button>
-->
<!-- -->
</template>
</modal>
@@ -197,10 +196,16 @@
v-bind:insideModal="false"
ref="dateAddress">
<template v-slot:before>
<button class="btn btn-misc" @click="openEditPane">
<i class="fa fa-fw fa-arrow-left"></i>
{{ $t('nav.previous')}}
</button>
</template>
<template v-slot:action>
<li>
<button class="btn btn-update" @click="closeDatePane">
{{ $t('action.edit')}}
<button class="btn btn-save" @click="closeDatePane">
{{ $t('action.save')}}
</button>
</li>
</template>
@@ -276,7 +281,7 @@ export default {
},
valid: {
from: new Date(),
to: new Date()
to: null
}
},
addressMap: {
@@ -330,11 +335,6 @@ export default {
},
mounted() {
//console.log('options displayText', this.options.button.displayText);
//console.log('options bindModal.step1', this.options.bindModal.step1);
//console.log('options bindModal.step2', this.options.bindModal.step2);
//console.log('options useDate.validFrom', this.options.useDate.validFrom);
//console.log('options useDate.validTo', this.options.useDate.validTo);
console.log('useDatePane', this.useDatePane);
console.log('Mounted now !');
@@ -380,7 +380,9 @@ export default {
console.log('displaySuggestions');
this.openSuggestPane();
} else {
this.initForm();
if (this.flag.datePane === false) {
this.initForm(); // reset form except if we come back from datePane
}
this.getCountries(); // will open editPane when resolve promise
}
},
@@ -456,11 +458,14 @@ export default {
fetchCountries().then(
countries => new Promise((resolve, reject) => {
this.entity.loaded.countries = countries.results;
if (this.flag.showPane === true) {
this.closeShowPane();
}
if (this.flag.suggestPane === true) {
this.closeSuggestPane();
}
if (this.flag.showPane === true) {
this.closeShowPane();
if (this.flag.datePane === true) {
this.flag.datePane = false;
}
console.log('step2: open the Edit panel');
this.flag.editPane = true;
@@ -600,8 +605,10 @@ export default {
if (this.context.target.name === 'person') { // !!! maintain here ?
postcodeBody = Object.assign(postcodeBody, {'origin': 3});
}
console.log('juste before post new postcode', postcodeBody);
return postPostalCode(postcodeBody)
.then(postalCode => {
console.log('new postcode created', postalCode.id);
payload.postcode = {'id': postalCode.id };
return this.postNewAddress(payload);
});

View File

@@ -9,29 +9,31 @@
{{ errorMsg }}
</div>
<address-render-box :address="address"></address-render-box>
<address-render-box :address="selectedAddress"></address-render-box>
<div v-if="showDateFrom" class='address-valid date-since'>
<h3>{{ $t(getValidFromDateText) }}</h3>
<div class="input-group mb-3">
<span class="input-group-text" id="validFrom"><i class="fa fa-fw fa-calendar"></i></span>
<input type="date" class="form-control form-control-lg" name="validFrom"
v-bind:placeholder="$t(getValidFromDateText)"
v-model="validFrom"
aria-describedby="validFrom"
/>
<div class="row">
<div v-if="showDateFrom" class='col-lg-6 address-valid date-since'>
<h3>{{ $t(getValidFromDateText) }}</h3>
<div class="input-group mb-3">
<span class="input-group-text" id="validFrom"><i class="fa fa-fw fa-calendar"></i></span>
<input type="date" class="form-control form-control-lg" name="validFrom"
v-bind:placeholder="$t(getValidFromDateText)"
v-model="validFrom"
aria-describedby="validFrom"
/>
</div>
</div>
</div>
<div v-if="showDateTo" class='address-valid date-until'>
<h3>{{ $t(getValidToDateText) }}</h3>
<div class="input-group mb-3">
<span class="input-group-text" id="validTo"><i class="fa fa-fw fa-calendar"></i></span>
<input type="date" class="form-control form-control-lg" name="validTo"
v-bind:placeholder="$t(getValidToDateText)"
v-model="validTo"
aria-describedby="validTo"
/>
<div v-if="showDateTo" class='col-lg-6 address-valid date-until'>
<h3>{{ $t(getValidToDateText) }}</h3>
<div class="input-group mb-3">
<span class="input-group-text" id="validTo"><i class="fa fa-fw fa-calendar"></i></span>
<input type="date" class="form-control form-control-lg" name="validTo"
v-bind:placeholder="$t(getValidToDateText)"
v-model="validTo"
aria-describedby="validTo"
/>
</div>
</div>
</div>
@@ -88,7 +90,7 @@ export default {
this.entity.selected.valid.to = ISOToDate(value);
},
get() {
return dateToISO(this.entity.selected.valid.from);
return dateToISO(this.entity.selected.valid.to);
}
},
getValidFromDateText() {
@@ -102,6 +104,35 @@ export default {
},
showDateTo() {
return !this.context.edit && this.options.useDate.validTo;
},
selectedAddress() {
let address = {};
address['country'] = (this.entity.selected.country) ? this.entity.selected.country : null;
address['postcode'] = (this.entity.selected.postcode) ? this.entity.selected.postcode : null;
if (this.entity.selected.address) {
let number = (this.entity.selected.address.streetNumber) ? this.entity.selected.address.streetNumber : null;
let street = (this.entity.selected.address.street) ? this.entity.selected.address.street : null;
address['text'] = number + ', ' + street;
address['street'] = (this.entity.selected.address.street) ? this.entity.selected.address.street : null;
address['streetNumber'] = (this.entity.selected.address.streetNumber) ? this.entity.selected.address.streetNumber : null;
address['floor'] = (this.entity.selected.address.floor) ? this.entity.selected.address.floor : null;
address['corridor'] = (this.entity.selected.address.corridor) ? this.entity.selected.address.corridor : null;
address['steps'] = (this.entity.selected.address.steps) ? this.entity.selected.address.steps : null;
address['flat'] = (this.entity.selected.address.flat) ? this.entity.selected.address.flat : null;
address['buildingName'] = (this.entity.selected.address.buildingName) ? this.entity.selected.address.buildingName : null;
address['distribution'] = (this.entity.selected.address.distribution) ? this.entity.selected.address.distribution : null;
address['extra'] = (this.entity.selected.address.extra) ? this.entity.selected.address.extra : null;
}
if (this.entity.selected.valid) {
address['validFrom'] = (this.entity.selected.valid.from) ? dateToISO(this.entity.selected.valid.from) : null;
address['validTo'] = (this.entity.selected.valid.to) ? dateToISO(this.entity.selected.valid.to) : null;
}
return address;
}
}
}

View File

@@ -21,7 +21,7 @@
</p>
</div>
<address-render-box :address="address"></address-render-box>
<address-render-box :address="address" :useDatePane="useDatePane"></address-render-box>
</div>
<action-buttons
@@ -56,7 +56,8 @@ export default {
'defaultz',
'flag',
'entity',
'errorMsg'
'errorMsg',
'useDatePane'
],
emits: ['openEditPane'],
computed: {