mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
fix #I947I0 16版本的app_odoo_customize增加功能,可对菜单信息显示debug
This commit is contained in:
90
app_odoo_customize/static/src/js/navbar.js
Normal file
90
app_odoo_customize/static/src/js/navbar.js
Normal file
@@ -0,0 +1,90 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import {NavBar} from '@web/webclient/navbar/navbar';
|
||||
import {useEffect, useRef} from '@odoo/owl';
|
||||
import {patch} from 'web.utils';
|
||||
import config from 'web.config';
|
||||
import {qweb} from 'web.core';
|
||||
|
||||
patch(NavBar.components.MenuDropdown.prototype, 'app_odoo_customize/static/src/js/menu_dropdown.js', {
|
||||
setup() {
|
||||
this._super();
|
||||
useEffect(() => this.addDebugTooltip());
|
||||
},
|
||||
addDebugTooltip() {
|
||||
if (config.isDebug()) {
|
||||
let dropdownDebugData = this.getDebugData()
|
||||
$(this.rootRef.el).find('.dropdown-toggle')
|
||||
.removeAttr('title')
|
||||
.tooltip(this.getDebugTooltip(dropdownDebugData));
|
||||
var self = this;
|
||||
_.each($(this.rootRef.el).find('.dropdown-menu_group'), function (menuGroup, index) {
|
||||
let $menuGroup = $(menuGroup);
|
||||
let menuGroupDebugData = self.getMenuGroupDebugData($menuGroup);
|
||||
$menuGroup.tooltip(self.getDebugTooltip(menuGroupDebugData));
|
||||
})
|
||||
}
|
||||
},
|
||||
getDebugData() {
|
||||
return {
|
||||
title: this.props.payload.name,
|
||||
xmlid: this.props.payload.xmlid,
|
||||
sequence: this.props.payload.sequence,
|
||||
}
|
||||
},
|
||||
getMenuGroupDebugData($menuGroup) {
|
||||
return {
|
||||
title: $menuGroup.data('name'),
|
||||
xmlid: $menuGroup.data('xmlid'),
|
||||
sequence: $menuGroup.data('sequence'),
|
||||
}
|
||||
},
|
||||
getDebugTooltip(debugData) {
|
||||
return {
|
||||
template: '<div class="tooltip tooltip-field-info" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>',
|
||||
title: qweb.render('Menu.tooltip', debugData),
|
||||
};
|
||||
}
|
||||
})
|
||||
NavBar.components.MenuDropdown.props.payload = {
|
||||
type: Object,
|
||||
optional: true,
|
||||
};
|
||||
patch(NavBar.components.DropdownItem.prototype, 'app_odoo_customize/static/src/js/menu_item.js', {
|
||||
setup() {
|
||||
this._super();
|
||||
useEffect(() => this.addDebugTooltip());
|
||||
},
|
||||
addDebugTooltip() {
|
||||
if (config.isDebug()) {
|
||||
let menuDebugData = this.getDebugData();
|
||||
if (!menuDebugData) {
|
||||
return;
|
||||
}
|
||||
$(`.dropdown-item[data-menu-xmlid="${menuDebugData.xmlid}"], .dropdown-item[data-section="${menuDebugData.id}"]`)
|
||||
.removeAttr('title')
|
||||
.tooltip(this.getDebugTooltip(menuDebugData));
|
||||
}
|
||||
},
|
||||
getDebugData() {
|
||||
if (!this.props.payload) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
id: this.props.payload.id,
|
||||
title: this.props.payload.name,
|
||||
xmlid: this.props.payload.xmlid,
|
||||
sequence: this.props.payload.sequence,
|
||||
}
|
||||
},
|
||||
getDebugTooltip(debugData) {
|
||||
return {
|
||||
template: '<div class="tooltip tooltip-field-info" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>',
|
||||
title: qweb.render('Menu.tooltip', debugData),
|
||||
};
|
||||
}
|
||||
})
|
||||
NavBar.components.DropdownItem.props.payload = {
|
||||
type: Object,
|
||||
optional: true,
|
||||
};
|
||||
58
app_odoo_customize/static/src/xml/debug_templates.xml
Normal file
58
app_odoo_customize/static/src/xml/debug_templates.xml
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-inherit="web.NavBar" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//DropdownItem" position="attributes">
|
||||
<attribute name="payload">currentApp</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
<t t-inherit="web.NavBar.AppsMenu" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//DropdownItem" position="attributes">
|
||||
<attribute name="payload">app</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
<t t-inherit="web.NavBar.SectionsMenu" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//DropdownItem" position="attributes">
|
||||
<attribute name="payload">section</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//MenuDropdown" position="attributes">
|
||||
<attribute name="payload">section</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
<t t-inherit="web.NavBar.SectionsMenu.Dropdown.MenuSlot" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//DropdownItem" position="attributes">
|
||||
<attribute name="payload">item</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[hasclass('dropdown-menu_group')]" position="attributes">
|
||||
<attribute name="t-att-data-name">item.name</attribute>
|
||||
<attribute name="t-att-data-xmlid">item.xmlid</attribute>
|
||||
<attribute name="t-att-data-sequence">item.sequence</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
<t t-inherit="web.NavBar.SectionsMenu.MoreDropdown" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//DropdownItem" position="attributes">
|
||||
<attribute name="payload">section</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
<t t-name="Menu.tooltip">
|
||||
<div class="oe_tooltip_string" if="title" role="tooltip">
|
||||
<t t-esc="title"/>
|
||||
</div>
|
||||
<ul class="oe_tooltip_technical" role="tooltip">
|
||||
<li t-if="xmlid">
|
||||
<span class="oe_tooltip_technical_title">XMLID:</span>
|
||||
<t t-esc="xmlid"/>
|
||||
</li>
|
||||
<li t-if="typeof sequence === 'number'">
|
||||
<span class="oe_tooltip_technical_title">Sequence:</span>
|
||||
<t t-esc="sequence"/>
|
||||
</li>
|
||||
</ul>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
Reference in New Issue
Block a user