Skip to content

Commit f06673a

Browse files
committed
⚡ Active / Hover item background color should work for main and sub menu (split it)
Signed-off-by: Enigma228322 <[email protected]>
1 parent bfd2f00 commit f06673a

File tree

4 files changed

+94
-23
lines changed

4 files changed

+94
-23
lines changed

theme_kit/models/theme.py

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ class ThemeTopPanel(models.Model):
104104
default=False, help="Active item Background color for Top Panel"
105105
)
106106

107+
top_panel_active_subitem_bg = fields.Char(
108+
"Active submenu item Background color",
109+
help="Active item Background color for Top Panel",
110+
)
111+
top_panel_active_subitem_bg_active = fields.Boolean(
112+
default=False, help="Active submenu item Background color for Top Panel"
113+
)
114+
107115
top_panel_hover_item_font = fields.Char(
108116
"Hover item Font color", help="Hover item Font color for Top Panel"
109117
)
@@ -117,6 +125,12 @@ class ThemeTopPanel(models.Model):
117125
top_panel_hover_item_bg_active = fields.Boolean(
118126
default=False, help="Hover item Background color for Top Panel"
119127
)
128+
top_panel_hover_subitem_bg = fields.Char(
129+
"Hover submenu item Background color", help="Hover item Background color for Top Panel"
130+
)
131+
top_panel_hover_subitem_bg_active = fields.Boolean(
132+
default=False, help="Hover submenu item Background color for Top Panel"
133+
)
120134

121135
# Compatibility theme_kit and material backend theme modules
122136
left_panel_main_menu = fields.Char(
@@ -163,10 +177,14 @@ def write(self, vals):
163177
self.top_panel_hover_item_font = ""
164178
if not vals.get("top_panel_hover_item_bg_active", "Not found"):
165179
self.top_panel_hover_item_bg = ""
180+
if not vals.get("top_panel_hover_subitem_bg_active", "Not found"):
181+
self.top_panel_hover_subitem_bg = ""
166182
if not vals.get("left_panel_main_menu_active", "Not found"):
167183
self.left_panel_main_menu = ""
168184
if not vals.get("left_panel_sub_menu_active", "Not found"):
169185
self.top_panel_hover_item_bg = ""
186+
if not vals.get("top_panel_active_subitem_bg_active", "Not found"):
187+
self.top_panel_active_subitem_bg = ""
170188

171189
@api.multi
172190
def _compute_less(self):
@@ -310,6 +328,16 @@ def _compute_less(self):
310328
code
311329
+ """.navbar-nav .active a{{
312330
background-color: {theme.top_panel_active_item_bg}!important;
331+
}}
332+
#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > a.active{{
333+
background-color: {theme.top_panel_active_item_bg}!important;
334+
}}"""
335+
)
336+
if self.top_panel_active_subitem_bg_active:
337+
code = (
338+
code
339+
+ """#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > ul > li.active > a{{
340+
background-color: {theme.top_panel_active_subitem_bg}!important;
313341
}}"""
314342
)
315343
if self.top_panel_hover_item_font_active:
@@ -348,31 +376,22 @@ def _compute_less(self):
348376
"""
349377
)
350378
if self.top_panel_hover_item_bg_active:
379+
# Compatibility theme_kit and material backend theme modules
351380
code = (
352381
code
353-
+ """.o_main_navbar > ul > li > a:hover{{
354-
background-color: {theme.top_panel_hover_item_bg}!important;
355-
}}
356-
.o_main_navbar > ul > li > a:focus{{
357-
background-color: {theme.top_panel_hover_item_bg}!important;
358-
}}
359-
.navbar-nav li a:hover{{
360-
background-color: {theme.top_panel_hover_item_bg}!important;
361-
}}
362-
.navbar-nav li a:focus{{
363-
background-color: {theme.top_panel_hover_item_bg}!important;
364-
}}
365-
.o_main_navbar > .o_menu_toggle:hover{{
366-
background-color: {theme.top_panel_hover_item_bg}!important;
382+
+ """#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > a:hover{{
383+
background-color: {theme.top_panel_hover_item_bg} !important;
367384
}}
368-
.o_main_navbar > .o_menu_toggle:focus{{
369-
background-color: {theme.top_panel_hover_item_bg}!important;
385+
#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > a:focus{{
386+
background-color: {theme.top_panel_hover_item_bg} !important;
370387
}}
371-
.open .dropdown-menu > li a:hover {{
372-
background-color: {theme.top_panel_hover_item_bg}!important;
373-
}}
374-
.open .dropdown-menu > li a:focus {{
375-
background-color: {theme.top_panel_hover_item_bg}!important;
388+
"""
389+
)
390+
if self.top_panel_hover_subitem_bg_active:
391+
code = (
392+
code
393+
+ """#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > ul > li > a:hover {{
394+
background: {theme.top_panel_hover_subitem_bg} !important;
376395
}}
377396
"""
378397
)
@@ -624,6 +643,9 @@ def _compute_less(self):
624643
.o_mail_chat .o_mail_chat_sidebar .o_mail_chat_channel_item.o_active {{
625644
background-color: {theme.left_panel_active_item_bg}!important;
626645
}}
646+
#sidebar > li > a.active{{
647+
background-color: {theme.left_panel_active_item_bg}!important;
648+
}}
627649
"""
628650
)
629651
if self.left_panel_hover_item_font_active:

theme_kit/static/js/theme_kit.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* Copyright 2020 Vildan Safin <https://www.it-projects.info/team/Enigma228322>
2+
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).*/
3+
odoo.define('theme_kit.model', function (require) {
4+
"use strict";
5+
6+
var WebClient = require("web.WebClient");
7+
8+
WebClient.include({
9+
init: function (parent) {
10+
this._super.apply(this, arguments);
11+
var self = this;
12+
},
13+
});
14+
$(document).ready(function(e){
15+
$('#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > a').click(function (e) {
16+
if($('#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > a') != undefined){
17+
$('#odooMenuBarNav > div > div.o_sub_menu_content > ul > li > a').removeClass("active");
18+
$("#odooMenuBarNav > div > div.o_sub_menu_content > ul > li.active").removeClass("active")
19+
}
20+
$(e.target).addClass("active");
21+
});
22+
$("#sidebar > li > a").click(function(e){
23+
if($("#sidebar > li > a") != undefined){
24+
$("#sidebar > li > a").removeClass("active");
25+
}
26+
$(e.target).addClass("active");
27+
});
28+
});
29+
});

theme_kit/views/templates.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
<t t-call="theme_kit.custom_css" />
1515
</xpath>
1616
</template>
17-
<template id="theme_kit.dummy">
18-
</template>
17+
<template
18+
id="theme_kit"
19+
name="Theme kit JS"
20+
inherit_id="web.assets_backend"
21+
>
22+
<xpath expr="." position="inside">
23+
<script
24+
type="text/javascript"
25+
src="/theme_kit/static/js/theme_kit.js"
26+
/>
27+
</xpath>
28+
</template>
1929
</odoo>

theme_kit/views/theme.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@
8585
<field name="top_panel_active_item_bg_active" nolabel="1" class="oe_inline"/>
8686
<field name="top_panel_active_item_bg" widget="color" attrs="{'readonly':[('top_panel_active_item_bg_active','=',False)]}" class="oe_inline"/>
8787
</div>
88+
<div>
89+
<label for="top_panel_active_subitem_bg" />
90+
<field name="top_panel_active_subitem_bg_active" nolabel="1" class="oe_inline"/>
91+
<field name="top_panel_active_subitem_bg" widget="color" attrs="{'readonly':[('top_panel_active_subitem_bg_active','=',False)]}" class="oe_inline"/>
92+
</div>
8893
<div>
8994
<label for="top_panel_hover_item_font" />
9095
<field name="top_panel_hover_item_font_active" nolabel="1" class="oe_inline"/>
@@ -95,6 +100,11 @@
95100
<field name="top_panel_hover_item_bg_active" nolabel="1" class="oe_inline"/>
96101
<field name="top_panel_hover_item_bg" widget="color" attrs="{'readonly':[('top_panel_hover_item_bg_active','=',False)]}" class="oe_inline"/>
97102
</div>
103+
<div>
104+
<label for="top_panel_hover_subitem_bg" />
105+
<field name="top_panel_hover_subitem_bg_active" nolabel="1" class="oe_inline"/>
106+
<field name="top_panel_hover_subitem_bg" widget="color" attrs="{'readonly':[('top_panel_hover_subitem_bg_active','=',False)]}" class="oe_inline"/>
107+
</div>
98108
</group>
99109
</group>
100110
</sheet>

0 commit comments

Comments
 (0)