Browse Source

Jan 04 [UPDT] : Updated 'code_backend_theme_enterprise'

pull/358/merge
AjmalCybro 4 months ago
parent
commit
667a25649c
  1. 8
      code_backend_theme_enterprise/__manifest__.py
  2. 5
      code_backend_theme_enterprise/doc/RELEASE_NOTES.md
  3. 150
      code_backend_theme_enterprise/static/src/js/chrome/sidebar.js
  4. 2
      code_backend_theme_enterprise/static/src/scss/sidebar.scss
  5. 26
      code_backend_theme_enterprise/static/src/xml/sidebar_templates.xml
  6. 35
      code_backend_theme_enterprise/static/src/xml/top_bar_templates.xml

8
code_backend_theme_enterprise/__manifest__.py

@ -21,7 +21,7 @@
#############################################################################
{
"name": "Code Backend Theme Enterprise",
"version": "18.0.1.0.0",
"version": "18.0.1.0.1",
"category": "Themes/Backend",
"summary": "Minimalist and elegant backend theme for Odoo Enterprise",
"description": """Minimalist and elegant backend theme for Odoo Backend""",
@ -36,16 +36,13 @@
'assets': {
'web.assets_backend': [
"code_backend_theme_enterprise/static/src/xml/top_bar_templates.xml",
"code_backend_theme_enterprise/static/src/xml/sidebar_templates.xml",
"code_backend_theme_enterprise/static/src/scss/sidebar.scss",
"code_backend_theme_enterprise/static/src/js/chrome/sidebar.js",
"code_backend_theme_enterprise/static/src/js/fields/colors.js",
"code_backend_theme_enterprise/static/src/scss/theme_accent.scss",
"code_backend_theme_enterprise/static/src/scss/datetimepicker.scss",
"code_backend_theme_enterprise/static/src/scss/theme.scss",
"https://fonts.googleapis.com/css2?family=Poppins:wght@400;700"
"&display=swap",
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js",
"https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap",
],
'web.assets_frontend': [
"code_backend_theme_enterprise/static/src/scss/login.scss",
@ -57,7 +54,6 @@
'static/description/banner.jpg',
'static/description/theme_screenshot.jpg',
],
'icon':'static/description/icon.png',
'license': 'LGPL-3',
'installable': True,
'auto_install': False,

5
code_backend_theme_enterprise/doc/RELEASE_NOTES.md

@ -3,3 +3,8 @@
#### Version 18.0.1.0.0
##### ADD
Initial commit for Code Backend Theme Enterprise
#### 09.01.2025
#### Version 18.0.1.0.1
#### UPDT
- Code Refactoring

150
code_backend_theme_enterprise/static/src/js/chrome/sidebar.js

@ -1,55 +1,109 @@
// Utility function to apply CSS styles and class modifications
function adjustLayoutOnSidebarToggle(isOpen) {
const actionManager = $(".o_action_manager");
const sidebarIcon = $(".side_bar_icon");
const navbar = $(".o_main_navbar");
const topHeading = $(".top_heading");
if (isOpen) {
$("#sidebar_panel").show();
if (window.matchMedia("(min-width: 768px)").matches) {
actionManager.css({ 'margin-left': '200px', 'transition': 'all .1s linear' });
sidebarIcon.css({ 'margin-left': '200px', 'transition': 'all .1s linear' });
}
navbar.addClass("small_nav").addClass(navbar.data("id"));
actionManager.addClass("sidebar_margin").addClass(actionManager.data("id"));
topHeading.addClass("sidebar_margin").addClass(topHeading.data("id"));
} else {
$("#sidebar_panel").hide();
actionManager.css({ 'margin-left': '0px' });
sidebarIcon.css({ 'margin-left': '0px' });
navbar.removeClass("small_nav").removeClass(navbar.data("id"));
actionManager.removeClass("sidebar_margin").removeClass(actionManager.data("id"));
topHeading.removeClass("sidebar_margin").removeClass(topHeading.data("id"));
}
}
/** @odoo-module **/
// Toggle sidebar visibility on click
$(document).on("click", "#openSidebar", () => {
$("#openSidebar").hide();
$("#closeSidebar").show();
adjustLayoutOnSidebarToggle(true);
});
import { NavBar } from '@web/webclient/navbar/navbar';
import { patch } from "@web/core/utils/patch";
$(document).on("click", "#closeSidebar", () => {
$("#closeSidebar").hide();
$("#openSidebar").show();
adjustLayoutOnSidebarToggle(false);
});
import {Component, onWillDestroy, useExternalListener, onMounted, useRef, onWillUnmount,} from "@odoo/owl";
patch(NavBar.prototype, {
setup() {
super.setup();
this.openElement = useRef("openSidebar");
this.closeElement = useRef("closeSidebar");
this.topHeading = useRef("sidebar_icon");
this.sidebarLinks = useRef("sidebarLinks");
const sidebarLinkHandler = this.handleSidebarLinkClick.bind(this);
const openSidebarHandler = this.openSidebar.bind(this);
const closeSidebarHandler = this.closeSidebar.bind(this);
onMounted(() => {
const openSidebarElement = this.openElement.el
const closeSidebarElement = this.closeElement.el
const sidebarLinkElements = this.sidebarLinks.el.children;
if (sidebarLinkElements) {
Array.from(sidebarLinkElements).forEach(link => {
link.addEventListener('click', sidebarLinkHandler);
});
}
if (openSidebarElement) {
openSidebarElement.addEventListener('click', openSidebarHandler);
}
if (closeSidebarElement) {
closeSidebarElement.addEventListener('click', closeSidebarHandler);
}
});
onWillUnmount(() => {
const openSidebarElement = this.openElement.el
const closeSidebarElement = this.closeElement.el
const sidebarLinkElements = this.sidebarLinks.el.children;
if (openSidebarElement) {
openSidebarElement.removeEventListener('click', openSidebarHandler);
}
if (closeSidebarElement) {
closeSidebarElement.removeEventListener('click', closeSidebarHandler);
}
if (sidebarLinkElements) {
Array.from(sidebarLinkElements).forEach(link => {
link.removeEventListener('click', sidebarLinkHandler);
});
}
});
},
// Handle menu item clicks
$(document).on("click", ".sidebar a", function () {
const $this = $(this);
const menuItems = $(".sidebar a");
openSidebar() {
this.root.el.nextElementSibling.style.marginLeft = '200px';
this.root.el.nextElementSibling.style.transition = 'all .1s linear';
const openSidebarElement = this.openElement.el
const closeSidebarElement = this.closeElement.el
if (openSidebarElement) openSidebarElement.style.display = 'none';
if (closeSidebarElement) closeSidebarElement.style.display = 'block';
if (this.root.el.lastChild && this.root.el.lastChild.nodeType === Node.ELEMENT_NODE) {
this.root.el.lastChild.style.display = 'block';
}
menuItems.removeClass("active");
$this.addClass("active");
if (this.topHeading.el && this.topHeading.el.nodeType === Node.ELEMENT_NODE) {
this.topHeading.el.style.marginLeft = '200px';
this.topHeading.el.style.transition = 'all .1s linear';
this.topHeading.el.style.width = 'auto';
}
},
// Adjust the header to reflect the active menu
$("header").removeClass().addClass($this.data("id"));
closeSidebar() {
console.log('Sidebar closed', this.topHeading);
this.root.el.nextElementSibling.style.marginLeft = '0px';
this.root.el.nextElementSibling.style.transition = 'all .1s linear';
const openSidebarElement = this.openElement.el
const closeSidebarElement = this.closeElement.el
if (openSidebarElement) openSidebarElement.style.display = 'block';
if (closeSidebarElement) closeSidebarElement.style.display = 'none';
if (this.root.el.lastChild && this.root.el.lastChild.nodeType === Node.ELEMENT_NODE) {
this.root.el.lastChild.style.display = 'none';
}
if (this.topHeading.el && this.topHeading.el.nodeType === Node.ELEMENT_NODE) {
this.topHeading.el.style.marginLeft = '0px';
this.topHeading.el.style.width = 'auto';
}
},
// Close sidebar after menu item selection
adjustLayoutOnSidebarToggle(false);
$("#closeSidebar").hide();
$("#openSidebar").show();
handleSidebarLinkClick(event) {
const closeSidebarElement = this.closeElement.el
if (closeSidebarElement) closeSidebarElement.style.display = 'none';
if (this.topHeading.el && this.topHeading.el.nodeType === Node.ELEMENT_NODE) {
this.topHeading.el.style.marginLeft = '0px';
}
if (this.topHeading.el && this.topHeading.el.nodeType === Node.ELEMENT_NODE) {
this.topHeading.el.style.marginLeft = '0px';
this.topHeading.el.style.width = '100%';
}
const li = event.currentTarget;
const a = li.firstElementChild;
const id = a.getAttribute('data-id');
document.querySelector('header').className = id;
Array.from(this.sidebarLinks.el.children).forEach(li => {
li.firstElementChild.classList.remove('active');
});
a.classList.add('active');
this.closeSidebar();
}
});

2
code_backend_theme_enterprise/static/src/scss/sidebar.scss

@ -95,3 +95,5 @@
display: block !important;
}
}

26
code_backend_theme_enterprise/static/src/xml/sidebar_templates.xml

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<!-- Extend the web.NavBar template to add a sidebar -->
<t t-name="code_backend_theme_enterprice.sidebar" t-inherit="web.NavBar" t-inherit-mode="extension" owl="1">
<!-- Add the sidebar panel right after the navbar -->
<xpath expr="//nav[hasclass('o_main_navbar')]" position="after">
<div class="sidebar_panel" id="sidebar_panel">
<div class="sidebar">
<!-- Sidebar close button -->
<div class="sidebar_close">
<a id="closeSidebar" style="cursor: pointer;">
<img src="/code_backend_theme_enterprise/static/src/img/icons/close.png"/>
</a>
</div>
<!-- Sidebar logo -->
<div class="sidebar_logo">
<img src="/web/binary/company_logo" class="logo_img"/>
</div>
<!-- Additional sidebar content can go here -->
</div>
</div>
</xpath>
</t>
</templates>

35
code_backend_theme_enterprise/static/src/xml/top_bar_templates.xml

@ -4,29 +4,38 @@
owl="1">
<!-- Sidebar button -->
<xpath expr="//a" position="replace">
<a href="#" class="o_menu_toggle" accesskey="h" t-ref="menuApps" t-on-click.prevent="() => this.hm.toggle()">
<svg width="14px" height="14px" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg">
<g t-foreach="[0, 5, 10]" t-as="Y" t-att-id="'o_menu_toggle_row_' + Y_index" fill="currentColor" t-key="'o_menu_toggle_row_' + Y_index">
<rect t-foreach="[0, 5, 10]" t-as="X" width="4" height="4" t-att-x="X" t-att-y="Y" t-key="'o_menu_toggle_cell_' + X_index"/>
<a href="#" class="o_menu_toggle" accesskey="h" t-ref="menuApps"
t-on-click.prevent="() => this.hm.toggle()">
<svg width="14px" height="14px" viewBox="0 0 14 14"
xmlns="http://www.w3.org/2000/svg">
<g t-foreach="[0, 5, 10]" t-as="Y"
t-att-id="'o_menu_toggle_row_' + Y_index"
fill="currentColor"
t-key="'o_menu_toggle_row_' + Y_index">
<rect t-foreach="[0, 5, 10]" t-as="X" width="4"
height="4" t-att-x="X" t-att-y="Y"
t-key="'o_menu_toggle_cell_' + X_index"/>
</g>
</svg>
</a>
<span t-if="1" class="side_bar_icon">
<span t-if="1" class="side_bar_icon" t-ref="sidebar_icon">
<!-- Toggle buttons with OWL click handlers -->
<a id="openSidebar"
<a id="openSidebar" t-ref="openSidebar"
t-attf-style="display: {{ state.isSidebarOpen ? 'none' : 'block' }}; cursor: pointer;">
<i class="fa fa-arrow-circle-right fa-2x"/>
</a>
<a id="closeSidebar"
<a id="closeSidebar" t-ref="closeSidebar"
t-attf-style="display: {{ state.isSidebarOpen ? 'block' : 'none' }}; cursor: pointer;">
<i class="fa fa-arrow-circle-left fa-2x"/>
</a>
</span>
</xpath>
<!-- Sidebar content -->
<xpath expr="//nav" position="after">
<span class="sidebar_panel" id="sidebar_panel" t-attf-style="display: {{ state.isSidebarOpen ? 'block' : 'none' }}">
<span class="sidebar_panel" id="sidebar_panel"
t-attf-style="display: {{ state.isSidebarOpen ? 'block' : 'none' }}">
<div class="sidebar">
<div class="sidebar_close">
<a id="closeSidebar" style="cursor: pointer;">
@ -37,12 +46,14 @@
<img src="/web/binary/company_logo" class="logo_img"/>
</div>
<h6 class="sidebar_head">MENU</h6>
<ul class="sidebar_menu">
<t t-foreach="menuService.getApps()" t-as="app" t-key="app.id">
<ul class="sidebar_menu" t-ref="sidebarLinks">
<t t-foreach="menuService.getApps()" t-as="app"
t-key="app.id">
<li>
<a role="menuitem"
t-attf-href="/odoo/{{app.actionPath}}"
class="nav-link">
t-attf-href="/odoo/{{app.actionPath}}"
class="nav-link"
t-on-click="() => this.onNavBarDropdownItemSelection(app)">
<img class="sidebar_img"
t-attf-src="{{app.webIconData}}"/>
<span class="sidebar_app_name">

Loading…
Cancel
Save