mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
improve addAddress
This commit is contained in:
@@ -27,7 +27,7 @@ export default {
|
||||
},
|
||||
key() {
|
||||
return (this.context.edit) ? 'address_' + this.context.addressId
|
||||
: this.context.entity.name + '_' + this.context.entity.id ;
|
||||
: this.context.target.name + '_' + this.context.target.id ;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@@ -45,9 +45,7 @@ export default {
|
||||
if (this.context.edit) {
|
||||
|
||||
// address is already linked, just finish !
|
||||
if (this.options.forceRedirect === true) {
|
||||
window.location.assign(this.context.backUrl);
|
||||
}
|
||||
this.$refs.addAddress.lastPaneAction();
|
||||
|
||||
// New created address
|
||||
} else {
|
||||
@@ -85,15 +83,18 @@ export default {
|
||||
* Post new created address to targetEntity
|
||||
*/
|
||||
postAddressTo(payload) {
|
||||
console.log('postAddressTo', payload.entity);
|
||||
switch (payload.entity) {
|
||||
console.log('postAddressTo', payload.target);
|
||||
switch (payload.target) {
|
||||
case 'household':
|
||||
postAddressToHousehold(payload.entityId, payload.addressId)
|
||||
postAddressToHousehold(payload.targetId, 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);
|
||||
|
||||
// finish
|
||||
this.$refs.addAddress.lastPaneAction();
|
||||
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
@@ -103,12 +104,15 @@ export default {
|
||||
;
|
||||
break;
|
||||
case 'person':
|
||||
postAddressToPerson(payload.entityId, payload.addressId)
|
||||
postAddressToPerson(payload.targetId, 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);
|
||||
|
||||
// finish
|
||||
this.$refs.addAddress.lastPaneAction();
|
||||
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
|
Reference in New Issue
Block a user