From bc86183d37715a8bf44c3fa222dd175156561d02 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Thu, 10 Mar 2022 10:20:01 +0000 Subject: [PATCH] [REM] mass_mailing: remove the option to change templates during edition The "Select a template" tab will be replaced with a a design tab. This removes the code that managed that tab. task-2789287 Part-of: odoo/odoo#86881 --- .../static/src/js/mass_mailing_widget.js | 73 +------------------ 1 file changed, 2 insertions(+), 71 deletions(-) diff --git a/addons/mass_mailing/static/src/js/mass_mailing_widget.js b/addons/mass_mailing/static/src/js/mass_mailing_widget.js index b08706eb757..71e66f6e123 100644 --- a/addons/mass_mailing/static/src/js/mass_mailing_widget.js +++ b/addons/mass_mailing/static/src/js/mass_mailing_widget.js @@ -402,8 +402,6 @@ var MassMailingFieldHtml = FieldHtml.extend({ var selectorToKeep = '.o_we_external_history_buttons, .email_designer_top_actions'; // Overide `d-flex` class which style is `!important` $snippetsSideBar.find(`.o_we_website_top_actions > *:not(${selectorToKeep})`).attr('style', 'display: none!important'); - var $snippets_menu = $snippetsSideBar.find("#snippets_menu"); - var $selectTemplateBtn = $snippets_menu.find('.o_we_select_template'); if (config.device.isMobile) { $snippetsSideBar.hide(); @@ -460,9 +458,6 @@ var MassMailingFieldHtml = FieldHtml.extend({ * Create theme selection screen and check if it must be forced opened. * Reforce it opened if the last snippet is removed. */ - const $themeSelector = $(core.qweb.render("mass_mailing.theme_selector", { - themes: themesParams - })); const $themeSelectorNew = $(core.qweb.render("mass_mailing.theme_selector_new", { themes: themesParams, templates: templatesParams, @@ -475,74 +470,15 @@ var MassMailingFieldHtml = FieldHtml.extend({ $themeSelectorNew.appendTo(this.wysiwyg.$iframeBody); } - /** - * Add proposition to install enterprise themes if not installed. - */ - var $mail_themes_upgrade = $themeSelector.find(".o_mass_mailing_themes_upgrade"); - $mail_themes_upgrade.on("click", function (e) { - e.stopImmediatePropagation(); - e.preventDefault(); - self.do_action("mass_mailing.action_mass_mailing_configuration"); - }); - - $selectTemplateBtn.on('click', () => { - $snippetsSideBar.data('snippetMenu').activateCustomTab($themeSelector); - /** - * Ensure the parent of the theme selector is not used as parent for a - * tooltip as it is overflow auto and would result in the tooltip being - * hidden by the body of the mail. - */ - $themeSelector.parent().addClass('o_forbidden_tooltip_parent'); - $selectTemplateBtn.addClass('active'); - }); - - /** - * Switch theme when a theme button is hovered. Confirm change if the theme button - * is pressed. - */ - var selectedTheme = false; - $themeSelector.on("mouseenter", ".dropdown-item", function (e) { - e.preventDefault(); - var themeParams = themesParams[$(e.currentTarget).index()]; - self.wysiwyg.odooEditor.automaticStepSkipStack(); - self._switchThemes(themeParams); - }); - $themeSelector.on("mouseleave", ".dropdown-item", function (e) { - if (self.$lastContent) { - self._switchThemes(Object.assign({}, selectedTheme, {template: self.$lastContent})); - } else { - self._switchThemes(selectedTheme); - } - }); - $themeSelector.on("click", '[data-toggle="dropdown"]', function (e) { - var $menu = $themeSelector.find('.dropdown-menu'); - var isVisible = $menu.hasClass('show'); - if (isVisible) { - e.preventDefault(); - e.stopImmediatePropagation(); - $menu.removeClass('show'); - } - }); - - const selectTheme = (themeParams) => { + let selectedTheme = false; + const selectTheme = themeParams => { self._switchImages(themeParams, $snippets); - selectedTheme = themeParams; - // Notify form view - $themeSelector.find('.dropdown-item.selected').removeClass('selected'); - $themeSelector.find('.dropdown-item:eq(' + themesParams.indexOf(selectedTheme) + ')').addClass('selected'); - // Invalidate previous content. self.$lastContent = undefined; }; - $themeSelector.on('click', '.dropdown-item', (e) => { - e.preventDefault(); - e.stopImmediatePropagation(); - const themeParams = themesParams[$(e.currentTarget).index()]; - selectTheme(themeParams); - }); $themeSelectorNew.on('click', '.dropdown-item', async (e) => { e.preventDefault(); e.stopImmediatePropagation(); @@ -559,10 +495,6 @@ var MassMailingFieldHtml = FieldHtml.extend({ $themeSelectorNew.remove(); - if ($mail_themes_upgrade.length) { - $snippets_menu.empty(); - } - selectTheme(themeParams); this._addEditorMessages(); // Wait the next tick because some mutation have to be processed by @@ -598,7 +530,6 @@ var MassMailingFieldHtml = FieldHtml.extend({ selectedTheme = this._getSelectedTheme(themesParams); if (selectedTheme) { this.$content.closest('body').addClass(selectedTheme.className); - $themeSelector.find('.dropdown-item:eq(' + themesParams.indexOf(selectedTheme) + ')').addClass('selected'); this._switchImages(selectedTheme, $snippets); } else if (this.$content.find('.o_layout').length) { themesParams.push({