From cb68632d8a3da706eed28c2b901b1d142b6cb749 Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Wed, 6 Jul 2022 12:22:47 +0000 Subject: [PATCH] [IMP] website: open the theme_install_kanban_action in the webclient Before this commit, the switchTheme option was redirecting the window to the theme_install_kanban_action url. After [1] was merged, the editor is instantiated inside the webclient and the action can now be opened directly from there, without a reload. For that, the request_save event data can include an 'action' parameter, which the WysiwygAdapter will use after leaving debug mode to trigger the action with the action service. [1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b task-2687506 closes odoo/odoo#81485 Signed-off-by: Quentin Smetz (qsm) --- .../src/components/wysiwyg_adapter/wysiwyg_adapter.js | 6 ++++++ addons/website/static/src/js/editor/snippets.options.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js index 6256ad0c1d5..87d05095a2f 100644 --- a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js +++ b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js @@ -30,6 +30,7 @@ export class WysiwygAdapterComponent extends ComponentAdapter { this.rpc = useWowlService('rpc'); this.orm = useWowlService('orm'); this.dialogs = useWowlService('dialog'); + this.action = useWowlService('action'); this.oeStructureSelector = '#wrapwrap .oe_structure[data-oe-xpath][data-oe-id]'; this.oeFieldSelector = '#wrapwrap [data-oe-field]'; @@ -558,6 +559,11 @@ export class WysiwygAdapterComponent extends ComponentAdapter { const currentPath = encodeURIComponent(window.location.pathname); const websiteId = this.websiteService.currentWebsite.id; callback = () => window.location = `/web#action=website.website_preview&website_id=${websiteId}&path=${currentPath}&enable_editor=1`; + } else if (event.data.action) { + callback = () => { + this.websiteService.leaveEditMode(); + this.action.doAction(event.data.action); + }; } if (isDirty) { return this.save().then(callback); diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index 78759aee1ca..0babf937e95 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -1186,7 +1186,7 @@ options.registry.OptionsTab = options.Class.extend({ } this.trigger_up('request_save', { reload: false, - onSuccess: () => window.location.href = '/web#action=website.theme_install_kanban_action', + action: 'website.theme_install_kanban_action', }); },