mirror of
https://github.com/odoo/design-themes.git
synced 2025-10-07 01:18:52 +07:00
a5a838e84f
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#1035
X-original-commit: c0d9b76f86
Related: odoo/odoo#191245
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
44 lines
1.5 KiB
JavaScript
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',
|
|
});
|