From 20651945c5bcad6e1b3fe76d671e5551aac562ca Mon Sep 17 00:00:00 2001 From: MuK IT GmbH Date: Sun, 23 Jun 2019 00:34:08 +0000 Subject: [PATCH] publish muk_web_theme - 12.0 --- muk_web_theme/__manifest__.py | 2 +- muk_web_theme/static/src/js/chrome/actions.js | 43 ++++++++++ muk_web_theme/static/src/js/chrome/apps.js | 81 ++++++++++--------- muk_web_theme/static/src/js/chrome/menu.js | 7 +- muk_web_theme/static/src/scss/layout.scss | 4 + muk_web_theme/template/assets.xml | 1 + 6 files changed, 97 insertions(+), 41 deletions(-) create mode 100644 muk_web_theme/static/src/js/chrome/actions.js diff --git a/muk_web_theme/__manifest__.py b/muk_web_theme/__manifest__.py index 5609a8c..4a7e3b5 100644 --- a/muk_web_theme/__manifest__.py +++ b/muk_web_theme/__manifest__.py @@ -19,7 +19,7 @@ { "name": "MuK Backend Theme", "summary": "Odoo Community Backend Theme", - "version": "12.0.1.5.11", + "version": "12.0.1.5.12", "category": "Themes/Backend", "license": "AGPL-3", "author": "MuK IT", diff --git a/muk_web_theme/static/src/js/chrome/actions.js b/muk_web_theme/static/src/js/chrome/actions.js new file mode 100644 index 0000000..b9f0609 --- /dev/null +++ b/muk_web_theme/static/src/js/chrome/actions.js @@ -0,0 +1,43 @@ +/********************************************************************************** +* +* Copyright (C) 2017 MuK IT GmbH +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License as +* published by the Free Software Foundation, either version 3 of the +* License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +* +**********************************************************************************/ + +odoo.define('muk_web_theme.ActionManager', function (require) { +"use strict"; + +var core = require('web.core'); +var config = require("web.config"); + +var ActionManager = require('web.ActionManager'); + +var _t = core._t; +var QWeb = core.qweb; + +ActionManager.include({ + _handleAction: function (action) { + return this._super.apply(this, arguments).always($.proxy(this, '_hideMenusByAction', action)); + }, + _hideMenusByAction: function (action) { + var unique_selection = '[data-action-id=' + action.id + ']'; + $(_.str.sprintf('.o_menu_apps .dropdown:has(.dropdown-menu.show:has(%s)) > a', unique_selection)).dropdown('toggle'); + $(_.str.sprintf('.o_menu_sections li.show:has(%s) .dropdown-toggle', unique_selection)).dropdown('toggle'); + $(_.str.sprintf('.o_menu_sections.show:has(%s)', unique_selection)).collapse('hide'); + }, +}); + +}); \ No newline at end of file diff --git a/muk_web_theme/static/src/js/chrome/apps.js b/muk_web_theme/static/src/js/chrome/apps.js index 978772a..5d06921 100644 --- a/muk_web_theme/static/src/js/chrome/apps.js +++ b/muk_web_theme/static/src/js/chrome/apps.js @@ -33,8 +33,9 @@ AppsMenu.include({ events: _.extend({}, AppsMenu.prototype.events, { "keydown .mk_search_input input": "_onSearchResultsNavigate", "click .mk_menu_search_result": "_onSearchResultChosen", - "shown.bs.dropdown": "_onMenuShow", - "hidden.bs.dropdown": "_onMenuHide", + "shown.bs.dropdown": "_onMenuShown", + "hidden.bs.dropdown": "_onMenuHidden", + "hide.bs.dropdown": "_onMenuHide", }), init: function (parent, menuData) { this._super.apply(this, arguments); @@ -53,49 +54,12 @@ AppsMenu.include({ this.$search_results = this.$(".mk_search_results"); return this._super.apply(this, arguments); }, - _onAppsMenuItemClicked: function (event) { - this._super.apply(this, arguments); - event.preventDefault(); - }, - _findNames: function (memo, menu) { - if (menu.action) { - var key = menu.parent_id ? menu.parent_id[1] + "/" : ""; - memo[key + menu.name] = menu; - } - if (menu.children.length) { - _.reduce(menu.children, this._findNames.bind(this), memo); - } - return memo; - }, - _setBackgroundImage: function () { - var url = session.url('/web/image', { - model: 'res.company', - id: session.company_id, - field: 'background_image', - }); - this.$('.dropdown-menu').css({ - "background-size": "cover", - "background-image": "url(" + url + ")" - }); - if (session.muk_web_theme_background_blend_mode) { - this.$('.o-app-name').css({ - "mix-blend-mode": session.muk_web_theme_background_blend_mode, - }); - } - }, _menuInfo: function (key) { var original = this._searchableMenus[key]; return _.extend({ action_id: parseInt(original.action.split(',')[1], 10), }, original); }, - _onMenuShow: function(event) { - this._searchFocus(); - }, - _onMenuHide: function(event) { - this._searchReset(); - - }, _searchFocus: function () { if (!config.device.isMobile) { this.$search_input.focus(); @@ -188,6 +152,45 @@ AppsMenu.include({ }, }); }, + _onAppsMenuItemClicked: function (event) { + this._super.apply(this, arguments); + event.preventDefault(); + }, + _findNames: function (memo, menu) { + if (menu.action) { + var key = menu.parent_id ? menu.parent_id[1] + "/" : ""; + memo[key + menu.name] = menu; + } + if (menu.children.length) { + _.reduce(menu.children, this._findNames.bind(this), memo); + } + return memo; + }, + _setBackgroundImage: function () { + var url = session.url('/web/image', { + model: 'res.company', + id: session.company_id, + field: 'background_image', + }); + this.$('.dropdown-menu').css({ + "background-size": "cover", + "background-image": "url(" + url + ")" + }); + if (session.muk_web_theme_background_blend_mode) { + this.$('.o-app-name').css({ + "mix-blend-mode": session.muk_web_theme_background_blend_mode, + }); + } + }, + _onMenuShown: function(event) { + this._searchFocus(); + }, + _onMenuHidden: function(event) { + this._searchReset(); + }, + _onMenuHide: function(event) { + return $('.oe_wait').length === 0 && !this.$('input').is(':focus'); + }, }); }); \ No newline at end of file diff --git a/muk_web_theme/static/src/js/chrome/menu.js b/muk_web_theme/static/src/js/chrome/menu.js index 91afc9d..5165e65 100644 --- a/muk_web_theme/static/src/js/chrome/menu.js +++ b/muk_web_theme/static/src/js/chrome/menu.js @@ -34,6 +34,7 @@ Menu.include({ "click .mk_menu_mobile_section": "_onMobileSectionClick", "click .o_menu_sections [role=menuitem]": "_hideMobileSubmenus", "show.bs.dropdown .o_menu_systray, .o_menu_apps": "_hideMobileSubmenus", + "hide.bs.dropdown .o_menu_sections": "_hideMenuSection", }), menusTemplate: config.device.isMobile ? 'muk_web_theme.MobileMenu.sections' : Menu.prototype.menusTemplate, @@ -46,10 +47,14 @@ Menu.include({ return this._super.apply(this, arguments); }, _hideMobileSubmenus: function () { - if (this.$menu_toggle.is(":visible") && this.$section_placeholder.is(":visible")) { + if (this.$menu_toggle.is(":visible") && $('.oe_wait').length === 0 && + this.$section_placeholder.is(":visible")) { this.$section_placeholder.collapse("hide"); } }, + _hideMenuSection: function () { + return $('.oe_wait').length === 0; + }, _updateMenuBrand: function () { if (!config.device.isMobile) { return this._super.apply(this, arguments); diff --git a/muk_web_theme/static/src/scss/layout.scss b/muk_web_theme/static/src/scss/layout.scss index 6a5b94d..fbee233 100644 --- a/muk_web_theme/static/src/scss/layout.scss +++ b/muk_web_theme/static/src/scss/layout.scss @@ -49,6 +49,10 @@ $mk-brand-gradient: linear-gradient(to right bottom, $mk-brand-gradient-start, $ } } +.oe_wait { + cursor: progress; +} + //---------------------------------------------------------- // Views //---------------------------------------------------------- diff --git a/muk_web_theme/template/assets.xml b/muk_web_theme/template/assets.xml index 5ddacb3..39e08c7 100644 --- a/muk_web_theme/template/assets.xml +++ b/muk_web_theme/template/assets.xml @@ -57,6 +57,7 @@ +