diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue index a1496e7d6..e72e26c14 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue @@ -42,8 +42,24 @@ export default { }, submitAddress(payload) { console.log('@@@ click on Submit Address Button', payload); - this.addDateToAddressAndPostAddressTo(payload); // !! + + // Existing address + if (this.context.edit) { + + // address is already linked, just finish ! + if (this.options.forceRedirect === true) { + window.location.assign(this.context.backUrl); + } + + // New created address + } else { + this.postAddressTo(payload); + } }, + + /* + * Patch date + * TO MOVE in DatePane addDateToAddressAndPostAddressTo(payload) { payload.body = { validFrom: { @@ -65,48 +81,48 @@ export default { this.$refs.addAddress.flag.loading = false; }); }, + */ + + /* + * Post new created address to targetEntity + */ postAddressTo(payload) { console.log('postAddressTo', payload.entity); - if (!this.context.edit) { // !! - switch (payload.entity) { - case 'household': - postAddressToHousehold(payload.entityId, payload.addressId) - .then(household => new Promise((resolve, reject) => { - console.log('..toHousehold', household); - this.$refs.addAddress.flag.loading = false; - this.$refs.addAddress.flag.success = true; - window.location.assign(this.context.backUrl); - resolve(); - })) - .catch((error) => { - this.$refs.addAddress.errorMsg.push(error); - this.$refs.addAddress.flag.loading = false; - }) - ; - break; - case 'person': - postAddressToPerson(payload.entityId, payload.addressId) - .then(person => new Promise((resolve, reject) => { - console.log('..toPerson', person); - this.$refs.addAddress.flag.loading = false; - this.$refs.addAddress.flag.success = true; - window.location.assign(this.context.backUrl); - resolve(); - })) - .catch((error) => { - this.$refs.addAddress.errorMsg.push(error); - this.$refs.addAddress.flag.loading = false; - }) - ; - break; - default: - this.$refs.addAddress.errorMsg.push('That entity is not managed by address !'); - } - } else { - // address is already linked, just finish ! - //window.location.assign(this.context.backUrl); + switch (payload.entity) { + case 'household': + postAddressToHousehold(payload.entityId, payload.addressId) + .then(household => new Promise((resolve, reject) => { + console.log('..toHousehold', household); + this.$refs.addAddress.flag.loading = false; + this.$refs.addAddress.flag.success = true; + window.location.assign(this.context.backUrl); + resolve(); + })) + .catch((error) => { + this.$refs.addAddress.errorMsg.push(error); + this.$refs.addAddress.flag.loading = false; + }) + ; + break; + case 'person': + postAddressToPerson(payload.entityId, payload.addressId) + .then(person => new Promise((resolve, reject) => { + console.log('..toPerson', person); + this.$refs.addAddress.flag.loading = false; + this.$refs.addAddress.flag.success = true; + window.location.assign(this.context.backUrl); + resolve(); + })) + .catch((error) => { + this.$refs.addAddress.errorMsg.push(error); + this.$refs.addAddress.flag.loading = false; + }) + ; + break; + default: + this.$refs.addAddress.errorMsg.push('That entity is not managed by address !'); } - }, + } } } 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 259266c92..27a9b6299 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -304,11 +304,9 @@ export default { console.log('getInitialAddress'); this.getInitialAddress(this.context.addressId); } - if (this.bypassFirstStep) { this.closeShowPane(); this.openEditPane(); - } else { this.flag.showPane = true; console.log('step0: open the Show Panel'); diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js index f54aaa407..193900c21 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js @@ -46,7 +46,9 @@ containers.forEach((container) => { useDate: { validFrom: container.dataset.useValidFrom === 'true', //boolean, default: false validTo: container.dataset.useValidTo === 'true' //boolean, default: false - } + }, + /// Force redirection after last step (cfr. backUrl) + forceRedirect: container.dataset.forceRedirect === 'true' //boolean, default: false } } } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig index bf996f593..ef8a9795c 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig @@ -18,6 +18,7 @@ * stickyActions bool (default: false) * useValidFrom bool (default: false) * useValidTo bool (default: false) + * forceRedirect bool (default: false) #}
{{ encore_entry_script_tags('vue_address') }}