fix: Optimize sidebar CSS generation and loading logic
This commit is contained in:
parent
032c6d3f1b
commit
4886662ea2
|
|
@ -40,11 +40,9 @@ class ResConfigSettings(models.TransientModel):
|
|||
"""Generate CSS rules for sidebar menu state"""
|
||||
if self.disable_nav_menu_section:
|
||||
return """
|
||||
/* Sidebar Menu Disabled - Hide Top Menu Sections */
|
||||
.o_main_navbar .o_menu_sections {
|
||||
{
|
||||
display: none !important;
|
||||
visibility: hidden !important;
|
||||
display: none!important;
|
||||
visibility: hidden!important;
|
||||
}
|
||||
"""
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { rpc } from "@web/core/network/rpc"
|
||||
|
||||
/**
|
||||
* Load and inject sidebar CSS rules based on configuration
|
||||
*/
|
||||
export function loadSidebarCSS() {
|
||||
// Get the RPC service
|
||||
const rpc = useService("rpc");
|
||||
|
||||
const loadCSS = async () => {
|
||||
try {
|
||||
|
|
@ -22,11 +19,13 @@ export function loadSidebarCSS() {
|
|||
kwargs: {},
|
||||
}
|
||||
);
|
||||
|
||||
console.log('Fetched sidebar CSS:', css);
|
||||
|
||||
if (css && css.trim()) {
|
||||
// Create a style element and inject the CSS
|
||||
const style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
// style.type = 'text/css';
|
||||
style.id = 'sidebar-dynamic-css';
|
||||
style.innerHTML = css;
|
||||
document.head.appendChild(style);
|
||||
|
|
@ -51,4 +50,4 @@ registry.category("web_tour.tours").add("sidebar_css_loader", {
|
|||
});
|
||||
|
||||
// Auto-load CSS on page load
|
||||
// loadSidebarCSS();
|
||||
loadSidebarCSS();
|
||||
|
|
|
|||
Loading…
Reference in New Issue