From 014446f84b2a13f6027eb6a62bb903041bfb28c8 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 30 Aug 2021 09:54:46 +0000 Subject: [PATCH] [FIX] web_editor, website: combine dataset "image" and "img" keys Commit [1] introduced a new "image" option instead of fixing the "img" option which already existed. Also it created a tag with a "fa-fw" class which does not make much sense. Also, our system with data-img actually creates a tag so that the color of the icon is the one decided in our SCSS instead of the one hardcoded in the image and so that there is an hover effect. [1]: https://github.com/odoo/odoo/commit/02ccad3200187724d5f133842032981fb91f7465 closes odoo/odoo#75743 Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/editor/snippets.options.js | 22 +++++++--------- .../src/img/snippets_options/palette.svg | 25 +++---------------- addons/website/views/snippets/snippets.xml | 2 +- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index c4e6bb0acee..1fac434bc09 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -902,19 +902,15 @@ const SelectUserValueWidget = BaseSelectionUserValueWidget.extend({ } this.menuTogglerEl = document.createElement('we-toggler'); - this.icon = this.el.dataset.icon || false; - this.image = this.el.dataset.image || false; - if (this.icon) { + this.iconEl = this.imgEl || null; + const icon = this.el.dataset.icon; + if (icon) { + this.iconEl = document.createElement('i'); + this.iconEl.classList.add('fa', 'fa-fw', icon); + } + if (this.iconEl) { this.el.classList.add('o_we_icon_select'); - const iconEl = document.createElement('i'); - iconEl.classList.add('fa', 'fa-fw', this.icon); - this.menuTogglerEl.appendChild(iconEl); - } else if (this.image) { - this.el.classList.add('o_we_icon_select'); - const imgEl = document.createElement('img'); - imgEl.src = this.image; - imgEl.classList.add('fa-fw'); - this.menuTogglerEl.appendChild(imgEl); + this.menuTogglerEl.appendChild(this.iconEl); } this.containerEl.insertBefore(this.menuTogglerEl, this.menuEl); @@ -955,7 +951,7 @@ const SelectUserValueWidget = BaseSelectionUserValueWidget.extend({ async setValue() { await this._super(...arguments); - if (this.icon || this.image) { + if (this.iconEl) { return; } diff --git a/addons/website/static/src/img/snippets_options/palette.svg b/addons/website/static/src/img/snippets_options/palette.svg index 8ef883653e1..00411e68226 100644 --- a/addons/website/static/src/img/snippets_options/palette.svg +++ b/addons/website/static/src/img/snippets_options/palette.svg @@ -1,23 +1,6 @@ - - - + + + + diff --git a/addons/website/views/snippets/snippets.xml b/addons/website/views/snippets/snippets.xml index df5e43c340d..4733f0c1916 100644 --- a/addons/website/views/snippets/snippets.xml +++ b/addons/website/views/snippets/snippets.xml @@ -1238,7 +1238,7 @@ data-use-css-color="true" data-selected-tab="custom-colors"/> - +