forked from Techsystech/web
[FIX] web_responsive: Change AppDrawer close method
Previous of this commit, AppDrawer closes when the action have an id that is defined in a menu item and no rpc calls are running. Now AppDrawer closes in a more generic way, is enough that a controller is attached to consider that the AppDrawer needs to be closed.14.0
parent
3a223fa490
commit
c42a1abfdb
|
@ -6,7 +6,7 @@
|
|||
{
|
||||
"name": "Web Responsive",
|
||||
"summary": "Responsive web client, community-supported",
|
||||
"version": "13.0.2.0.0",
|
||||
"version": "13.0.2.0.1",
|
||||
"category": "Website",
|
||||
"website": "https://github.com/OCA/web",
|
||||
"author": "LasLabs, Tecnativa, " "Odoo Community Association (OCA)",
|
||||
|
|
|
@ -17,12 +17,28 @@ odoo.define("web_responsive", function(require) {
|
|||
const ListRenderer = require("web.ListRenderer");
|
||||
const DocumentViewer = require("mail.DocumentViewer");
|
||||
|
||||
/*
|
||||
* Helper function to know if are waiting
|
||||
*
|
||||
/* Hide AppDrawer in desktop and mobile modes.
|
||||
* To avoid delays in pages with a lot of DOM nodes we make
|
||||
* sub-groups' with 'querySelector' to improve the performance.
|
||||
*/
|
||||
function isWaiting() {
|
||||
return $(".oe_wait").length !== 0;
|
||||
function closeAppDrawer() {
|
||||
_.defer(function() {
|
||||
// Need close AppDrawer?
|
||||
var menu_apps_dropdown = document.querySelector(".o_menu_apps .dropdown");
|
||||
$(menu_apps_dropdown)
|
||||
.has(".dropdown-menu.show")
|
||||
.find("> a")
|
||||
.dropdown("toggle");
|
||||
// Need close Sections Menu?
|
||||
// TODO: Change to 'hide' in modern Bootstrap >4.1
|
||||
var menu_sections = document.querySelector(
|
||||
".o_menu_sections li.show .dropdown-toggle"
|
||||
);
|
||||
$(menu_sections).dropdown("toggle");
|
||||
// Need close Mobile?
|
||||
var menu_sections_mobile = document.querySelector(".o_menu_sections.show");
|
||||
$(menu_sections_mobile).collapse("hide");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,6 +145,7 @@ odoo.define("web_responsive", function(require) {
|
|||
_onAppsMenuItemClicked: function(ev) {
|
||||
this._super.apply(this, arguments);
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -284,7 +301,7 @@ odoo.define("web_responsive", function(require) {
|
|||
* Control if AppDrawer can be closed
|
||||
*/
|
||||
_hideAppsMenu: function() {
|
||||
return !isWaiting() && !this.$("input").is(":focus");
|
||||
return !this.$("input").is(":focus");
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -297,10 +314,7 @@ odoo.define("web_responsive", function(require) {
|
|||
*/
|
||||
canBeDiscarded: function(recordID) {
|
||||
if (this.model.isDirty(recordID || this.handle)) {
|
||||
$(".o_menu_apps .dropdown:has(.dropdown-menu.show) > a").dropdown(
|
||||
"toggle"
|
||||
);
|
||||
$(".o_menu_sections li.show .dropdown-toggle").dropdown("toggle");
|
||||
closeAppDrawer();
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
@ -310,11 +324,9 @@ odoo.define("web_responsive", function(require) {
|
|||
events: _.extend(
|
||||
{
|
||||
// Clicking a hamburger menu item should close the hamburger
|
||||
"click .o_menu_sections [role=menuitem]": "_hideMobileSubmenus",
|
||||
"click .o_menu_sections [role=menuitem]": "_onClickMenuItem",
|
||||
// Opening any dropdown in the navbar should hide the hamburger
|
||||
"show.bs.dropdown .o_menu_systray, .o_menu_apps": "_hideMobileSubmenus",
|
||||
// Prevent close section menu
|
||||
"hide.bs.dropdown .o_menu_sections": "_hideMenuSection",
|
||||
},
|
||||
Menu.prototype.events
|
||||
),
|
||||
|
@ -329,21 +341,21 @@ odoo.define("web_responsive", function(require) {
|
|||
*/
|
||||
_hideMobileSubmenus: function() {
|
||||
if (
|
||||
config.device.isMobile &&
|
||||
this.$menu_toggle.is(":visible") &&
|
||||
this.$section_placeholder.is(":visible") &&
|
||||
!isWaiting()
|
||||
this.$section_placeholder.is(":visible")
|
||||
) {
|
||||
this.$section_placeholder.collapse("hide");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide Menu Section
|
||||
* Prevent hide the menu (should be closed when action is loaded)
|
||||
*
|
||||
* @returns {Boolean}
|
||||
* @param {ClickEvent} ev
|
||||
*/
|
||||
_hideMenuSection: function() {
|
||||
return !isWaiting();
|
||||
_onClickMenuItem: function(ev) {
|
||||
ev.stopPropagation();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -356,17 +368,6 @@ odoo.define("web_responsive", function(require) {
|
|||
return this._super.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Don't display the menu if are waiting for an action to end
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
_onMouseOverMenu: function() {
|
||||
if (!isWaiting()) {
|
||||
this._super.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
RelationalFields.FieldStatus.include({
|
||||
|
@ -455,42 +456,11 @@ odoo.define("web_responsive", function(require) {
|
|||
// Hide AppDrawer or Menu when the action has been completed
|
||||
ActionManager.include({
|
||||
/**
|
||||
* Because the menu aren't closed when click, this method
|
||||
* searchs for the menu with the action executed to close it.
|
||||
* To avoid delays in pages with a lot of DOM nodes we make
|
||||
* 'sub-groups' with 'querySelector' to improve the performance.
|
||||
*
|
||||
* @param {action} action
|
||||
* The executed action
|
||||
* @override
|
||||
*/
|
||||
_hideMenusByAction: function(action) {
|
||||
const uniq_sel = "[data-action-id=" + action.id + "]";
|
||||
// Need close AppDrawer?
|
||||
const menu_apps_dropdown = document.querySelector(".o_menu_apps .dropdown");
|
||||
$(menu_apps_dropdown)
|
||||
.has(".dropdown-menu.show")
|
||||
.has(uniq_sel)
|
||||
.find("> a")
|
||||
.dropdown("toggle");
|
||||
// Need close Sections Menu?
|
||||
const menu_sections = document.querySelector(".o_menu_sections li.show");
|
||||
$(menu_sections)
|
||||
.has(uniq_sel)
|
||||
.find(".dropdown-toggle")
|
||||
.dropdown("toggle");
|
||||
// Need close Mobile?
|
||||
const menu_sections_mobile = document.querySelector(
|
||||
".o_menu_sections.show"
|
||||
);
|
||||
$(menu_sections_mobile)
|
||||
.has(uniq_sel)
|
||||
.hide();
|
||||
},
|
||||
|
||||
_handleAction: function(action) {
|
||||
return this._super
|
||||
.apply(this, arguments)
|
||||
.finally($.proxy(this, "_hideMenusByAction", action));
|
||||
_appendController: function() {
|
||||
this._super.apply(this, arguments);
|
||||
closeAppDrawer();
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue