[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
This commit is contained in:
qsm-odoo
2021-10-05 14:18:00 +00:00
parent 27604376a9
commit 0efc4276fe
@@ -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',