Public release from ruodoo-project: 19.0 - 2026-11-08 22:50:01 UTC
This commit is contained in:
53
translation_helper/static/src/menus/dropdown.js
Normal file
53
translation_helper/static/src/menus/dropdown.js
Normal file
@@ -0,0 +1,53 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
// In Odoo 19, Dropdown uses an inline xml`` template (no QWeb template named web.Dropdown).
|
||||
// MenuTranslationButton is injected into DropdownItem via JS patch + XML template inheritance
|
||||
// of web.DropdownItem (NOT web.NavBar.DropdownItem which is unused as a component template).
|
||||
// NavBar is also patched to support translate buttons on section buttons with children.
|
||||
|
||||
import {DropdownItem} from "@web/core/dropdown/dropdown_item";
|
||||
import {NavBar} from "@web/webclient/navbar/navbar";
|
||||
import {MenuTranslationButton} from "./menu_translation_button";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
// Patch DropdownItem — for leaf menu items (no children)
|
||||
patch(DropdownItem, {
|
||||
components: {
|
||||
...DropdownItem.components,
|
||||
MenuTranslationButton,
|
||||
},
|
||||
});
|
||||
|
||||
patch(DropdownItem.prototype, {
|
||||
setup() {
|
||||
super.setup(...arguments);
|
||||
this.hasTranslation = this.getHasTranslation();
|
||||
},
|
||||
|
||||
onClick(ev) {
|
||||
if (ev.target.classList.contains("translate-middle-y")) {
|
||||
return;
|
||||
}
|
||||
super.onClick(ev);
|
||||
},
|
||||
|
||||
getHasTranslation() {
|
||||
return Boolean(odoo.translate);
|
||||
},
|
||||
});
|
||||
|
||||
// Patch NavBar — for section buttons with children (Dropdown-based)
|
||||
patch(NavBar, {
|
||||
components: {
|
||||
...NavBar.components,
|
||||
MenuTranslationButton,
|
||||
},
|
||||
});
|
||||
|
||||
patch(NavBar.prototype, {
|
||||
setup() {
|
||||
super.setup(...arguments);
|
||||
// expose to template via __translate__ variable
|
||||
this.__translate__ = Boolean(odoo.translate);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user