parent callback will cast afterLastPaneAction, that manage redirection or context changes

This commit is contained in:
2021-09-20 12:24:28 +02:00
parent 717cd03d95
commit 75a240a2d6
4 changed files with 21 additions and 16 deletions

View File

@@ -384,7 +384,9 @@ export default {
if (!this.context.edit && this.useDatePane) {
this.openDatePane();
} else {
this.openShowPane()
if (!this.options.forceRedirect) {
this.openShowPane();
}
}
},
openDatePane() {
@@ -402,13 +404,18 @@ export default {
this.flag.datePane = false;
this.openShowPane();
},
lastPaneAction() {
afterLastPaneAction(params) {
this.initForm();
// redirect or reset pane
if (this.options.forceRedirect === true) {
console.log("redirect to backUrl");
window.location.assign(this.context.backUrl);
} else {
console.log("don't redirect");
console.log("don't redirect, adapt context");
this.resetPane();
// change to edit context
this.context.edit = true;
this.context.addressId = params.addressId;
}
},
@@ -546,14 +553,14 @@ export default {
if (!this.context.edit) {
this.addNewAddress(newAddress)
.then(payload => this.closePaneAndCallbackSubmit(payload));
.then(payload => this.addressChangedCallback(payload));
} else {
this.updateAddress({
addressId: this.context.addressId,
newAddress: newAddress
})
.then(payload => this.closePaneAndCallbackSubmit(payload));
.then(payload => this.addressChangedCallback(payload));
}
},
@@ -655,18 +662,15 @@ export default {
/*
* Method just add closing pane to the callback method
* (get out step1 show pane, submit button)
*/
closePaneAndCallbackSubmit(payload)
{
this.initForm();
this.resetPane();
//this.initForm();
//this.resetPane(); // because parent callback will cast afterLastPaneAction()
console.log('will call parent callback method', payload);
// callback props method from parent
this.addressChangedCallback(payload);
}
*/
}
}
</script>