mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
AddAddress: adding a forceRedirect option
This commit is contained in:
parent
3f3b7af42b
commit
4855ec2065
@ -42,8 +42,24 @@ export default {
|
|||||||
},
|
},
|
||||||
submitAddress(payload) {
|
submitAddress(payload) {
|
||||||
console.log('@@@ click on Submit Address Button', 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) {
|
addDateToAddressAndPostAddressTo(payload) {
|
||||||
payload.body = {
|
payload.body = {
|
||||||
validFrom: {
|
validFrom: {
|
||||||
@ -65,48 +81,48 @@ export default {
|
|||||||
this.$refs.addAddress.flag.loading = false;
|
this.$refs.addAddress.flag.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Post new created address to targetEntity
|
||||||
|
*/
|
||||||
postAddressTo(payload) {
|
postAddressTo(payload) {
|
||||||
console.log('postAddressTo', payload.entity);
|
console.log('postAddressTo', payload.entity);
|
||||||
if (!this.context.edit) { // !!
|
switch (payload.entity) {
|
||||||
switch (payload.entity) {
|
case 'household':
|
||||||
case 'household':
|
postAddressToHousehold(payload.entityId, payload.addressId)
|
||||||
postAddressToHousehold(payload.entityId, payload.addressId)
|
.then(household => new Promise((resolve, reject) => {
|
||||||
.then(household => new Promise((resolve, reject) => {
|
console.log('..toHousehold', household);
|
||||||
console.log('..toHousehold', household);
|
this.$refs.addAddress.flag.loading = false;
|
||||||
this.$refs.addAddress.flag.loading = false;
|
this.$refs.addAddress.flag.success = true;
|
||||||
this.$refs.addAddress.flag.success = true;
|
window.location.assign(this.context.backUrl);
|
||||||
window.location.assign(this.context.backUrl);
|
resolve();
|
||||||
resolve();
|
}))
|
||||||
}))
|
.catch((error) => {
|
||||||
.catch((error) => {
|
this.$refs.addAddress.errorMsg.push(error);
|
||||||
this.$refs.addAddress.errorMsg.push(error);
|
this.$refs.addAddress.flag.loading = false;
|
||||||
this.$refs.addAddress.flag.loading = false;
|
})
|
||||||
})
|
;
|
||||||
;
|
break;
|
||||||
break;
|
case 'person':
|
||||||
case 'person':
|
postAddressToPerson(payload.entityId, payload.addressId)
|
||||||
postAddressToPerson(payload.entityId, payload.addressId)
|
.then(person => new Promise((resolve, reject) => {
|
||||||
.then(person => new Promise((resolve, reject) => {
|
console.log('..toPerson', person);
|
||||||
console.log('..toPerson', person);
|
this.$refs.addAddress.flag.loading = false;
|
||||||
this.$refs.addAddress.flag.loading = false;
|
this.$refs.addAddress.flag.success = true;
|
||||||
this.$refs.addAddress.flag.success = true;
|
window.location.assign(this.context.backUrl);
|
||||||
window.location.assign(this.context.backUrl);
|
resolve();
|
||||||
resolve();
|
}))
|
||||||
}))
|
.catch((error) => {
|
||||||
.catch((error) => {
|
this.$refs.addAddress.errorMsg.push(error);
|
||||||
this.$refs.addAddress.errorMsg.push(error);
|
this.$refs.addAddress.flag.loading = false;
|
||||||
this.$refs.addAddress.flag.loading = false;
|
})
|
||||||
})
|
;
|
||||||
;
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
this.$refs.addAddress.errorMsg.push('That entity is not managed by address !');
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -304,11 +304,9 @@ export default {
|
|||||||
console.log('getInitialAddress');
|
console.log('getInitialAddress');
|
||||||
this.getInitialAddress(this.context.addressId);
|
this.getInitialAddress(this.context.addressId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.bypassFirstStep) {
|
if (this.bypassFirstStep) {
|
||||||
this.closeShowPane();
|
this.closeShowPane();
|
||||||
this.openEditPane();
|
this.openEditPane();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.flag.showPane = true;
|
this.flag.showPane = true;
|
||||||
console.log('step0: open the Show Panel');
|
console.log('step0: open the Show Panel');
|
||||||
|
@ -46,7 +46,9 @@ containers.forEach((container) => {
|
|||||||
useDate: {
|
useDate: {
|
||||||
validFrom: container.dataset.useValidFrom === 'true', //boolean, default: false
|
validFrom: container.dataset.useValidFrom === 'true', //boolean, default: false
|
||||||
validTo: container.dataset.useValidTo === '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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
* stickyActions bool (default: false)
|
* stickyActions bool (default: false)
|
||||||
* useValidFrom bool (default: false)
|
* useValidFrom bool (default: false)
|
||||||
* useValidTo bool (default: false)
|
* useValidTo bool (default: false)
|
||||||
|
* forceRedirect bool (default: false)
|
||||||
#}
|
#}
|
||||||
<div class="address-container"
|
<div class="address-container"
|
||||||
|
|
||||||
@ -67,6 +68,10 @@
|
|||||||
{% if useValidTo is defined and useValidTo == 1 %}
|
{% if useValidTo is defined and useValidTo == 1 %}
|
||||||
data-use-valid-to="true"
|
data-use-valid-to="true"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if forceRedirect is defined and forceRedirect == 1 %}
|
||||||
|
data-force-redirect="true"
|
||||||
|
{% endif %}
|
||||||
></div>
|
></div>
|
||||||
|
|
||||||
{{ encore_entry_script_tags('vue_address') }}
|
{{ encore_entry_script_tags('vue_address') }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user