From 0efc4276febb84db7dc8af25b8856c64032fd8fc Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 4 Oct 2021 16:54:39 +0000 Subject: [PATCH] [FIX] website: properly show selected header links style Since [1], method names of user value widgets are sorted alphabetically to ensure consistency. This broke widgets using both the customizeWebsiteVariable and customizeWebsiteViews methods as the non-alphabetical order is unfortunately the right one there. Until a better system is implemented, this fix simply switch those two methods order specifically. [1]: https://github.com/odoo/odoo/commit/a48a30f954afcb6ff3a59c4f32b05fd0c2cfcd2b X-original-commit: 4ee47afb3709862c6ecd8e19e7aa7db5016e528e Part-of: odoo/odoo#77862 --- .../static/src/js/editor/snippets.options.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index b9dfacc6a19..d08118354a2 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -18,6 +18,26 @@ var qweb = core.qweb; const InputUserValueWidget = options.userValueWidgetsRegistry['we-input']; const SelectUserValueWidget = options.userValueWidgetsRegistry['we-select']; +options.UserValueWidget.include({ + loadMethodsData() { + this._super(...arguments); + + // Method names are sorted alphabetically by default. Exception here: + // we make sure, customizeWebsiteVariable is considered after + // customizeWebsiteViews so that the variable is used to show to active + // value when both methods are used at the same time. + // TODO find a better way. + const indexVariable = this._methodsNames.indexOf('customizeWebsiteVariable'); + if (indexVariable >= 0) { + const indexView = this._methodsNames.indexOf('customizeWebsiteViews'); + if (indexView >= 0) { + this._methodsNames[indexVariable] = 'customizeWebsiteViews'; + this._methodsNames[indexView] = 'customizeWebsiteVariable'; + } + } + }, +}); + const UrlPickerUserValueWidget = InputUserValueWidget.extend({ custom_events: _.extend({}, InputUserValueWidget.prototype.custom_events || {}, { 'website_url_chosen': '_onWebsiteURLChosen',