3
0
Fork 0

[IMP] show AppsMenu by default after login

also redirect to backend from website AppsMenu
15.0-ocabot-merge-pr-2789-by-pedrobaeza-bump-patch
Sergey Shebanin 2021-11-03 16:14:25 +03:00
parent 310c7156f4
commit a9daa2aea7
5 changed files with 126 additions and 0 deletions

View File

@ -18,6 +18,10 @@
"maintainers": ["Yajo", "Tardo", "SplashS"], "maintainers": ["Yajo", "Tardo", "SplashS"],
"data": ["views/res_users.xml", "views/web.xml"], "data": ["views/res_users.xml", "views/web.xml"],
"assets": { "assets": {
"web.assets_frontend": [
"/web_responsive/static/src/legacy/js/website_apps_menu.js",
"/web_responsive/static/src/legacy/css/website_apps_menu.scss",
],
"web.assets_backend": [ "web.assets_backend": [
"/web_responsive/static/src/legacy/css/web_responsive.scss", "/web_responsive/static/src/legacy/css/web_responsive.scss",
"/web_responsive/static/src/legacy/js/web_responsive.js", "/web_responsive/static/src/legacy/js/web_responsive.js",

View File

@ -10,10 +10,34 @@ import {useHotkey} from "@web/core/hotkeys/hotkey_hook";
import {scrollTo} from "@web/core/utils/scrolling"; import {scrollTo} from "@web/core/utils/scrolling";
import {debounce} from "@web/core/utils/timing"; import {debounce} from "@web/core/utils/timing";
import {fuzzyLookup} from "@web/core/utils/search"; import {fuzzyLookup} from "@web/core/utils/search";
import {WebClient} from "@web/webclient/webclient";
import {patch} from "web.utils";
const {Component} = owl; const {Component} = owl;
const {useState, useRef} = owl.hooks; const {useState, useRef} = owl.hooks;
// Patch WebClient to show AppsMenu instead of default app
patch(WebClient.prototype, "web_responsive.DefaultAppsMenu", {
setup() {
this._super();
useBus(Dropdown.bus, "state-changed", (payload) => {
if (payload.emitter.el.classList.contains("o_navbar_apps_menu")) {
this.el.classList.toggle("o_apps_menu_opened", payload.newState.open);
this.el.classList.toggle("o_first_app", false);
}
});
},
_loadDefaultApp() {
var menu_apps_dropdown = document.querySelector(
".o_navbar_apps_menu .dropdown-toggle"
);
menu_apps_dropdown.click();
this.el.classList.toggle("o_apps_menu_opened", true);
this.el.classList.toggle("o_first_app", true);
return true;
},
});
/** /**
* @extends Dropdown * @extends Dropdown
*/ */

View File

@ -12,6 +12,17 @@
width: 100vw; width: 100vw;
z-index: 200; z-index: 200;
left: 0 !important; left: 0 !important;
top: $o-navbar-height !important;
}
.o_first_app .o_navbar_apps_menu .dropdown-toggle {
display: none;
}
.o_apps_menu_opened .o_main_navbar {
.o_menu_brand,
.o_menu_sections {
display: none;
}
} }
// Iconized full screen apps menu // Iconized full screen apps menu

View File

@ -0,0 +1,35 @@
/* Copyright 2021 ITerra - Sergey Shebanin
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
// Website main navbar and his AppsMenu button
#oe_main_menu_navbar {
.dropdown-toggle::after {
display: none;
}
a.full {
> i {
padding: 0 10px 0 0;
font-size: 17px;
}
font-size: 20px;
line-height: 46px;
@include media-breakpoint-down(sm) {
width: 46px;
overflow: hidden;
}
}
#oe_applications.o_responsive_loaded {
a.full {
width: 46px;
overflow: hidden;
}
}
.o_menu_brand {
white-space: nowrap;
padding: 0 16px 0 4px;
text-transform: capitalize;
@include media-breakpoint-down(sm) {
display: none;
}
}
}

View File

@ -0,0 +1,52 @@
/* Copyright 2021 Sergey Shebanin
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
odoo.define("web_responsive.website_apps_menu", function (require) {
"use strict";
/*
* We can't require anything from website here because `web_responsive` doesn't depend on `website`.
* In this case we will try to get WebsiteNavbar class through the PublicRoot registry.
* WebsiteNavbar can be unavailable if `website` is not installed. In this case this file do nothing.
*/
const publicRoot = require("root.widget");
const lazyloader = require("web.public.lazyloader");
const registry = publicRoot._getRegistry();
function patchNavbar() {
const navbar = registry.get("WebsiteNavbar", false);
if (!navbar) return false;
navbar.Widget.include({
/**
* We don't need to load app menus
* @override
*/
async _loadAppMenus() {
return Promise.resolve();
},
/**
* We add a spinner for the user to understand the loading
* @override
*/
_onOeApplicationsShow: function () {
const icon = $(
document.querySelector("#oe_main_menu_navbar a.full > i")
);
icon.removeClass("fa fa-th-large").append(
$("<span/>", {class: "fa fa-spin fa-spinner"})
);
window.location.href = "/web#home";
// Prevent dropdown to be showed
return false;
},
});
const menu = $("#oe_applications");
menu.addClass("o_responsive_loaded").after(
"<span class='o_menu_brand'>" + menu.find("a.full").text() + "</span>"
);
return true;
}
// Try to patch navbar. If it is not in registry - make another try after lazyload
if (!patchNavbar()) {
lazyloader.allScriptsLoaded.then(patchNavbar);
}
});