Files
design-themes/test_themes/static/src/systray_items/website_switcher.js
T
qsm-odoo 0f4e8df0e1 [FIX] test_themes: restore the website switcher
The forward-port of [1] made no adaptation to the code, and it now
simply crashes when trying to use the website switcher when test_themes
is installed.

This also fixes a linter error introduced by that same [1] commit.

[1]: https://github.com/odoo/design-themes/commit/c3af5d9796929025c9503ab639afc8c60a262b3f

closes odoo/design-themes#1037

X-original-commit: a5a838e84f
Related: odoo/odoo#191567
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2024-12-24 08:45:12 +00:00

44 lines
1.5 KiB
JavaScript

/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import { useService } from '@web/core/utils/hooks';
import { WebsiteSwitcherSystray } from '@website/systray_items/website_switcher';
import { onMounted, useState } from "@odoo/owl";
patch(WebsiteSwitcherSystray.prototype, {
setup() {
super.setup();
this.orm = useService('orm');
this.tooltips = useState({});
// Disable the notification service to avoid having a notification for each theme.
this.notificationService = { add: () => () => null };
onMounted(async () => {
const themesWebsites = await this.orm.call('website', 'get_test_themes_websites_theme_preview');
for (const themeId in themesWebsites) {
this.tooltips[themeId] = {
"data-tooltip-template": 'test_themes.ThemeTooltip',
"data-tooltip-position": 'left',
"data-tooltip-delay": 100,
"data-tooltip-info": JSON.stringify({url: themesWebsites[themeId]}),
};
}
});
},
getElements() {
// Add tooltip information
const elements = super.getElements(...arguments);
return elements.map((elem) => {
elem.dataset = {
...elem.dataset,
...this.tooltips[elem.id]
};
return elem;
});
},
template: 'test_themes.WebsiteSwitcherSystray',
});