-
- Downloads
[FIX] web: restore dialog callback calls (e.g. cloning a website page)
Commit [1] broke some confirm dialogs because the confirm and cancel callbacks are not called with the same `this` anymore. E.g.: - Install website - Go to the page manager (/website/pages) - Clone a page (choose a name and confirm) => Crash (this.$ does not exist). Note that this flow was quickly fixed with [2] by changing the local code instead of fixing the root cause (this commit here actually technically reverts that change so it keeps working). The work done at [1] actually needed some more rework than that to handle two other potential usecases: - If the confirm dialog handlers' promises are rejected, the dialog is not closed (rightfully, like for example allowing to fill an empty required input)... but [1] prevented to click on the button again forever. With the same example as above, it can be reproduced: if the RPC to clone the page fails, I cannot retry. - If not both confirm_callback and cancel_callback were given, [1] only prevented to multi-click on the related button (e.g. if you click on "Ok", a RPC which takes 10 seconds is made, you click on cancel immediately afterwards -> the dialog is closed while it should be prevented (and would be if cancel_callback was given, following [1])). That may not be entirely stable to make this change though but it seems to make sense and be better (just keeping what [1] wanted here). Note: this adds some more tests to check all of this + some more things that were found during development. For example: [1] relied on the fact that callbacks returned a Promise or nothing... while developers actually were returning random things (for no reason as no way to get the result anyway). Adding a test for this prevents to break that in stable (the first iteration here crashed in such cases). [1]: https://github.com/odoo/odoo/commit/4b8b079a7d9991a8dc481fe71a45185d672135c9 [2]: https://github.com/odoo/odoo/commit/8216341f5ad8d82ad0bcb0d1f01d874477d2de7b Closes https://github.com/odoo/odoo/pull/103712 opw-3033878 opw-3043224 opw-3046485 opw-3042542 closes odoo/odoo#104220 Signed-off-by:Aaron Bohy (aab) <aab@odoo.com>
Showing
- addons/web/static/src/js/core/dialog.js 28 additions, 9 deletionsaddons/web/static/src/js/core/dialog.js
- addons/web/static/tests/core/dialog_tests.js 107 additions, 1 deletionaddons/web/static/tests/core/dialog_tests.js
- addons/website/static/src/js/menu/content.js 1 addition, 1 deletionaddons/website/static/src/js/menu/content.js
Loading