From 9f07e6a272e6d3365f5045ca23e2b10d7a21b3d8 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 24 Sep 2021 11:21:09 +0200 Subject: [PATCH] Address: fetch POST valid dates when applying changes from datePane --- .../Resources/public/vuejs/Address/App.vue | 26 -------------- .../vuejs/Address/components/AddAddress.vue | 34 +++++++++++++++---- .../vuejs/Address/components/DatePane.vue | 2 +- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue index d429098a5..72bd16bc4 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue @@ -53,32 +53,6 @@ export default { } }, - /* - * Patch date - * TO MOVE in DatePane - addDateToAddressAndPostAddressTo(payload) { - payload.body = { - validFrom: { - datetime: `${this.context.valid.from.toISOString().split('T')[0]}T00:00:00+0100` - } - }; - console.log('addDateToAddress', payload); - - this.$refs.addAddress.flag.loading = true; - return patchAddress(payload.addressId, payload.body) - .then(address => new Promise((resolve, reject) => { - this.context.valid.from = address.validFrom; - resolve(); - }) - .then(this.postAddressTo(payload)) - ) - .catch((error) => { - this.$refs.addAddress.errorMsg.push(error); - this.$refs.addAddress.flag.loading = false; - }); - }, - */ - /* * Post new created address to targetEntity */ diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue index 80668270f..38afeae80 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -299,14 +299,16 @@ export default { return (typeof this.options.openPanesInModal !== 'undefined') ? this.options.openPanesInModal : this.defaultz.openPanesInModal; }, - useDatePane() { - let vFrom = (typeof this.options.useDate !== 'undefined' - && typeof this.options.useDate.validFrom !== 'undefined') ? - this.options.useDate.validFrom : this.defaultz.useDate.validFrom ; - let vTo = (typeof this.options.useDate !== 'undefined' - && typeof this.options.useDate.validTo !== 'undefined') ? + validFrom() { + return (typeof this.options.useDate !== 'undefined' && typeof this.options.useDate.validFrom !== 'undefined') ? + this.options.useDate.validFrom : this.defaultz.useDate.validFrom; + }, + validTo() { + return (typeof this.options.useDate !== 'undefined' && typeof this.options.useDate.validTo !== 'undefined') ? this.options.useDate.validTo : this.defaultz.useDate.validTo ; - return (vFrom || vTo) ? true : false; + }, + useDatePane() { + return (this.validFrom || this.validTo) ? true : false; }, hasSuggestions() { // TODO @@ -335,6 +337,8 @@ export default { }, mounted() { + console.log('validFrom', this.validFrom); + console.log('validTo', this.validTo); console.log('useDatePane', this.useDatePane); console.log('Mounted now !'); @@ -566,6 +570,22 @@ export default { 'point': this.entity.selected.address.point.coordinates }); } + if (this.validFrom) { + console.log('add validFrom in fetch body', this.entity.selected.valid.from); + newAddress = Object.assign(newAddress, { + 'validFrom': { + datetime: `${this.entity.selected.valid.from.toISOString().split('T')[0]}T00:00:00+0100` + } + }); + } + if (this.validTo && null !== this.entity.selected.valid.to) { + console.log('add validTo in fetch body', this.entity.selected.valid.to); + newAddress = Object.assign(newAddress, { + 'validTo': { + datetime: `${this.entity.selected.valid.to.toISOString().split('T')[0]}T00:00:00+0100` + } + }); + } if (this.entity.selected.writeNew.postcode) { let newPostcode = this.entity.selected.postcode; newPostcode = Object.assign(newPostcode, { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/DatePane.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/DatePane.vue index 69e4ccea6..6a83cbfe2 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/DatePane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/DatePane.vue @@ -54,7 +54,7 @@