From c879ac723b341b951dd464f0a147012f36b912f7 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 31 Oct 2019 14:38:09 +0000 Subject: [PATCH] [FIX] website, *: no theme color suggestions during theme colors edition * web_editor Part of https://github.com/odoo/odoo/pull/38959 task-2066614 --- .../static/src/js/wysiwyg/widgets/color_palette.js | 5 +++++ addons/website/static/src/js/widgets/theme.js | 1 + 2 files changed, 6 insertions(+) diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js b/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js index 5c5ab0ca866..ed37d65f096 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js @@ -31,6 +31,7 @@ const ColorPaletteWidget = Widget.extend({ * @param {string} [options.colorPrefix='bg-'] Used for the class based colors (theme). * @param {boolean} [options.resetButton=true] Whether to display or not the reset button. * @param {string[]} [options.excluded=[]] Sections not to display. + * @param {string[]} [options.excludeSectionOf] Extra section to exclude: the one containing the named color. * @param {JQuery} [options.$editable=$()] Editable content from which the custom colors are retrieved. */ init: function (parent, options) { @@ -42,6 +43,7 @@ const ColorPaletteWidget = Widget.extend({ colorPrefix: 'bg-', resetButton: true, excluded: [], + excludeSectionOf: null, $editable: $(), }, options || {}); @@ -86,6 +88,9 @@ const ColorPaletteWidget = Widget.extend({ _.each(this.options.excluded, function (exc) { $wrapper.find('[data-name="' + exc + '"]').remove(); }); + if (this.options.excludeSectionOf) { + $wrapper.find('[data-name]:has([data-color="' + this.options.excludeSectionOf + '"])').remove(); + } // Render common colors if (!this.options.excluded.includes('common')) { diff --git a/addons/website/static/src/js/widgets/theme.js b/addons/website/static/src/js/widgets/theme.js index b14cfb2102f..8c544d790d7 100644 --- a/addons/website/static/src/js/widgets/theme.js +++ b/addons/website/static/src/js/widgets/theme.js @@ -519,6 +519,7 @@ var ThemeCustomizeDialog = Dialog.extend({ resetButton: false, defaultColor: $color.css('background-color'), excluded: ['transparent_grayscale'], + excludeSectionOf: colorName, }); var chosenColor = undefined; colorpicker.on('color_picked custom_color_picked', self, function (ev) {