From 2511323d87d2022bfd2e31aefd343692cd567da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Dieudonn=C3=A9?= Date: Thu, 17 Aug 2023 13:34:56 +0000 Subject: [PATCH] [REF] web, *: remove unused blockUI and unblockUI from legacy misc Since [1], these two functions are no longer used. We can now remove the entire file. Follow-up of [2] [1] https://github.com/odoo/enterprise/pull/45869 [2] https://github.com/odoo/odoo/pull/132072 Task ID: 3439226 Part-of: odoo/odoo#132295 --- addons/mrp_subcontracting/__manifest__.py | 1 - addons/project/__manifest__.py | 1 - addons/web/__manifest__.py | 2 - addons/web/static/src/legacy/js/core/misc.js | 98 -------------------- addons/web/static/src/legacy/js/env.js | 6 +- 5 files changed, 1 insertion(+), 107 deletions(-) delete mode 100644 addons/web/static/src/legacy/js/core/misc.js diff --git a/addons/mrp_subcontracting/__manifest__.py b/addons/mrp_subcontracting/__manifest__.py index 4a847ac215e..22412073d53 100644 --- a/addons/mrp_subcontracting/__manifest__.py +++ b/addons/mrp_subcontracting/__manifest__.py @@ -179,7 +179,6 @@ 'web/static/src/legacy/backend_utils.js', 'web/static/src/legacy/utils.js', 'web/static/src/legacy/js/core/dates.js', - 'web/static/src/legacy/js/core/misc.js', 'web/static/src/legacy/js/services/session.js', 'web/static/src/legacy/js/widgets/date_picker.js', 'web/static/src/legacy/js/env.js', diff --git a/addons/project/__manifest__.py b/addons/project/__manifest__.py index 3de25979b0e..b6c8f1ac0c0 100644 --- a/addons/project/__manifest__.py +++ b/addons/project/__manifest__.py @@ -230,7 +230,6 @@ 'web/static/src/legacy/backend_utils.js', 'web/static/src/legacy/utils.js', 'web/static/src/legacy/js/core/dates.js', - 'web/static/src/legacy/js/core/misc.js', 'web/static/src/legacy/js/services/session.js', 'web/static/src/legacy/js/widgets/date_picker.js', 'web/static/src/legacy/js/env.js', diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 0ac54b77e6e..2da5a94b0b8 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -170,7 +170,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/backend_utils.js', 'web/static/src/legacy/utils.js', 'web/static/src/legacy/js/core/dates.js', - 'web/static/src/legacy/js/core/misc.js', 'web/static/src/legacy/js/services/session.js', 'web/static/src/legacy/js/widgets/date_picker.js', 'web/static/src/legacy/js/env.js', @@ -307,7 +306,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/utils.js', 'web/static/src/legacy/js/core/dates.js', - 'web/static/src/legacy/js/core/misc.js', 'web/static/src/legacy/js/owl_compatibility.js', 'web/static/src/legacy/js/services/session.js', 'web/static/src/legacy/js/public/public_env.js', diff --git a/addons/web/static/src/legacy/js/core/misc.js b/addons/web/static/src/legacy/js/core/misc.js deleted file mode 100644 index c2ef65dbf43..00000000000 --- a/addons/web/static/src/legacy/js/core/misc.js +++ /dev/null @@ -1,98 +0,0 @@ -/** @odoo-module **/ - -import { _t } from "@web/core/l10n/translation"; -import Widget from "@web/legacy/js/core/widget"; - -var messages_by_seconds = function() { - return [ - [0, _t("Loading...")], - [20, _t("Still loading...")], - [60, _t("Still loading...
Please be patient.")], - [120, _t("Don't leave yet,
it's still loading...")], - [300, _t("You may not believe it,
but the application is actually loading...")], - [420, _t("Take a minute to get a coffee,
because it's loading...")], - [3600, _t("Maybe you should consider reloading the application by pressing F5...")] - ]; -}; - -var Throbber = Widget.extend({ - template: "Throbber", - start: function() { - this.start_time = new Date().getTime(); - this.act_message(); - }, - act_message: function() { - var self = this; - setTimeout(function() { - if (self.isDestroyed()) - return; - var seconds = (new Date().getTime() - self.start_time) / 1000; - var mes; - messages_by_seconds().forEach((el) => { - if (seconds >= el[0]) - mes = el[1]; - }); - self.$(".oe_throbber_message").html(mes); - self.act_message(); - }, 1000); - }, -}); - -/** Setup blockui */ -if ($.blockUI) { - $.blockUI.defaults.baseZ = 1100; - $.blockUI.defaults.message = '
'; - $.blockUI.defaults.css.border = '0'; - $.blockUI.defaults.css["background-color"] = ''; -} - - -/** - * Remove the "accesskey" attributes to avoid the use of the access keys - * while the blockUI is enable. - */ - -function blockAccessKeys() { - var elementWithAccessKey = []; - elementWithAccessKey = document.querySelectorAll('[accesskey]'); - elementWithAccessKey.forEach((elem) => { - elem.setAttribute("data-accesskey",elem.getAttribute('accesskey')); - elem.removeAttribute('accesskey'); - }); -} - -function unblockAccessKeys() { - var elementWithDataAccessKey = []; - elementWithDataAccessKey = document.querySelectorAll('[data-accesskey]'); - elementWithDataAccessKey.forEach((elem) => { - elem.setAttribute('accesskey', elem.getAttribute('data-accesskey')); - elem.removeAttribute('data-accesskey'); - }); -} - -var throbbers = []; - -export function blockUI() { - var tmp = $.blockUI.apply($, arguments); - var throbber = new Throbber(); - throbbers.push(throbber); - throbber.appendTo($(".oe_blockui_spin_container")); - $(document.body).addClass('o_ui_blocked'); - blockAccessKeys(); - return tmp; -} - -export function unblockUI() { - throbbers.forEach((throbber) => { - throbber.destroy(); - }); - throbbers = []; - $(document.body).removeClass('o_ui_blocked'); - unblockAccessKeys(); - return $.unblockUI.apply($, arguments); -} - -export default { - blockUI: blockUI, - unblockUI: unblockUI, -}; diff --git a/addons/web/static/src/legacy/js/env.js b/addons/web/static/src/legacy/js/env.js index 439fe70834a..459d9262d0e 100644 --- a/addons/web/static/src/legacy/js/env.js +++ b/addons/web/static/src/legacy/js/env.js @@ -5,9 +5,5 @@ */ import commonEnv from '@web/legacy/js/common_env'; -import { blockUI, unblockUI } from "@web/legacy/js/core/misc"; -const env = commonEnv; -env.services = Object.assign(env.services, { blockUI, unblockUI }); - -export default env; +export default commonEnv;