From dc1191f6939c4bbf5cfcc865884813610f4f8f2c Mon Sep 17 00:00:00 2001 From: FrancoisGe Date: Mon, 8 May 2023 10:17:10 +0000 Subject: [PATCH] [IMP] web: use customized closing function in dialog This commit allows a child component of a dialog to change the behaviour when you want to close that dialog. To change the behaviour of a dialog, the component must overwrite env.dialogData.close. closes odoo/odoo#120520 Signed-off-by: Lucas Perais (lpe) --- addons/web/static/src/core/dialog/dialog.js | 2 +- addons/web/static/src/core/dialog/dialog.xml | 8 +++--- .../src/webclient/actions/action_dialog.xml | 4 +-- addons/web/static/tests/core/dialog_tests.js | 27 +++++++++++++++++++ 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/core/dialog/dialog.js b/addons/web/static/src/core/dialog/dialog.js index 5da7dbd4b3b..23c256e7401 100644 --- a/addons/web/static/src/core/dialog/dialog.js +++ b/addons/web/static/src/core/dialog/dialog.js @@ -40,7 +40,7 @@ export class Dialog extends Component { this.data.close(); }); this.id = `dialog_${this.data.id}`; - useChildSubEnv({ inDialog: true, dialogId: this.id, closeDialog: this.data.close }); + useChildSubEnv({ inDialog: true, dialogId: this.id, closeDialog: () => this.data.close() }); this.position = useState({ left: 0, top: 0 }); useDialogDraggable({ ref: this.modalRef, diff --git a/addons/web/static/src/core/dialog/dialog.xml b/addons/web/static/src/core/dialog/dialog.xml index ae8bead3d41..d58da7bd02c 100644 --- a/addons/web/static/src/core/dialog/dialog.xml +++ b/addons/web/static/src/core/dialog/dialog.xml @@ -13,7 +13,7 @@