用户菜单调整
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
'name': '教育',
|
||||
'version': '18.0.3.0.9',
|
||||
'version': '18.0.3.1.0',
|
||||
'summary': 'Odoo 18 教学管理平台 — 师生管理 + 课程管理 + 作业/进展(老师·学生双角色)',
|
||||
'description': """
|
||||
Odoo 18 教学管理平台(面向老师与学生,双角色权限)
|
||||
|
||||
@@ -2,28 +2,38 @@
|
||||
<!--
|
||||
侧边栏窄模式悬浮提示
|
||||
|
||||
背景:udoo_om_ux 的左侧导航栏(.o_sidenav)拖窄/切换到窄模式(宽度 < 142 时
|
||||
加 .sm 类)后,菜单文字 .nav-title 被 display:none 隐藏,只剩图标,
|
||||
而 title 属性恰好在被隐藏的 span 上,导致鼠标悬停看不到任何菜单名提示。
|
||||
背景:udoo_om_ux 左侧导航栏(.o_sidenav)拖窄 / 切换窄模式(宽度 < 142 时加 .sm)
|
||||
后,菜单文字 .nav-title 被 display:none 隐藏、只剩图标,而原生 title 属性恰好在
|
||||
被隐藏的 span 上,导致鼠标悬停看不到任何菜单名提示。
|
||||
|
||||
方案:继承 wub.Sidenav.Item 模板,给 DropdownItem 的 attrs 增加 Odoo 原生
|
||||
data-tooltip(黑色气泡,与系统其他提示一致):
|
||||
- 仅当 ue.sidenavWidth < 142(即窄模式)时输出 data-tooltip;宽模式值为 false
|
||||
(owl 对 t-att 对象里值为 false 的键会省略该属性;注意不能写 null,
|
||||
null 会被渲染成字符串 "null" 出现在气泡里),不干扰展开状态;
|
||||
- tooltip 出现在图标右侧(侧边栏在左,往右弹最自然);想改回下方
|
||||
把 'right' 改成 'bottom' 即可。
|
||||
做法:继承 wub.NavBar.AppsMenu,给每个菜单外壳 div.nav-item 挂 Odoo 原生
|
||||
data-tooltip(黑色气泡,与系统其它提示一致),只在窄模式输出。
|
||||
|
||||
⚠ 为什么必须挂在外壳 div 上,而不是里面的 DropdownItem(踩过的坑):
|
||||
Odoo 在开发者模式(URL 带 ?debug=1,debug 值会存进 session)下,模板继承的
|
||||
applyInheritance() 会给每个被修改的元素「前面」插入一个调试注释节点
|
||||
(见 odoo/addons/web/static/src/core/template_inheritance.js:260)。
|
||||
- 如果改的是 .nav-item 的子元素,这个注释就成了 .nav-item 的 firstChild;
|
||||
而主题 OmuxNavBar.preSubnavTiming 里写死了
|
||||
evTarget.firstChild.classList.contains('on')
|
||||
注释节点没有 classList → 报
|
||||
TypeError: Cannot read properties of undefined (reading 'contains')
|
||||
- 改外壳后,注释落在 .sidenav_cont 里当兄弟节点:主题其它地方用的是
|
||||
element.children[...](只数元素,忽略注释),完全不受影响,悬停范围还是整行。
|
||||
|
||||
想改气泡方向把下面的 'right' 改成 'bottom' 即可。
|
||||
-->
|
||||
<templates xml:space="preserve">
|
||||
<t t-inherit="wub.Sidenav.Item" t-inherit-mode="extension">
|
||||
<xpath expr="//DropdownItem" position="attributes">
|
||||
<attribute name="attrs">{
|
||||
href: getMenuItemHref(app),
|
||||
'data-menu-xmlid': app.xmlid,
|
||||
'data-section': app.id,
|
||||
'data-tooltip': ue.sidenavWidth < 142 ? (app.label or app.name) : false,
|
||||
'data-tooltip-position': 'right'
|
||||
}</attribute>
|
||||
<t t-inherit="wub.NavBar.AppsMenu" t-inherit-mode="extension">
|
||||
<!-- 应用列表项(t-foreach 渲染出来的那一批) -->
|
||||
<xpath expr="//div[hasclass('nav-item')][@t-foreach]" position="attributes">
|
||||
<attribute name="t-att-data-tooltip">ue.sidenavWidth < 142 ? (app.label or app.name) : false</attribute>
|
||||
<attribute name="data-tooltip-position">right</attribute>
|
||||
</xpath>
|
||||
<!-- 收藏夹里「当前应用不在收藏中」时额外显示的那一项 -->
|
||||
<xpath expr="//div[hasclass('nav-item')][@t-if][not(@t-foreach)]" position="attributes">
|
||||
<attribute name="t-att-data-tooltip">ue.sidenavWidth < 142 ? (currentApp.label or currentApp.name) : false</attribute>
|
||||
<attribute name="data-tooltip-position">right</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
|
||||
Reference in New Issue
Block a user