[IMP] web,*: lazy load jSignature lib and extension

The jSignature lib is only used by the NameAndSignature component,
which is not accessible on a many screens. This commit thus
removes the lib and its extension from the bundles, and makes the
NameAndSignature component load it on demand.

Part of task~3439226

closes odoo/odoo#138054

Related: odoo/enterprise#48633
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
This commit is contained in:
Aaron Bohy
2023-10-11 08:18:46 +00:00
parent 4bf1384e8b
commit dc2be03dba
8 changed files with 11 additions and 16 deletions
@@ -87,11 +87,9 @@
'web/static/lib/bootstrap/js/dist/toast.js',
'web/static/lib/select2/select2.js',
'web/static/lib/clipboard/clipboard.js',
'web/static/lib/jSignature/jSignatureCustom.js',
'web/static/src/legacy/js/libs/autocomplete.js',
'web/static/src/legacy/js/libs/bootstrap.js',
'web/static/src/legacy/js/libs/jquery.js',
'web/static/src/legacy/js/libs/jSignatureCustom.js',
'web/static/src/legacy/js/core/bus.js',
'web/static/src/legacy/js/core/class.js',
'web/static/src/legacy/js/core/dialog.js',
-2
View File
@@ -137,11 +137,9 @@
'web/static/lib/bootstrap/js/dist/toast.js',
'web/static/lib/select2/select2.js',
'web/static/lib/clipboard/clipboard.js',
'web/static/lib/jSignature/jSignatureCustom.js',
'web/static/src/legacy/js/libs/autocomplete.js',
'web/static/src/legacy/js/libs/bootstrap.js',
'web/static/src/legacy/js/libs/jquery.js',
'web/static/src/legacy/js/libs/jSignatureCustom.js',
'web/static/src/legacy/js/core/bus.js',
'web/static/src/legacy/js/core/class.js',
'web/static/src/legacy/js/core/dialog.js',
+2 -5
View File
@@ -89,11 +89,9 @@ This module provides the core of the Odoo Web Client.
'web/static/lib/bootstrap/js/dist/toast.js',
'web/static/lib/select2/select2.js',
'web/static/lib/clipboard/clipboard.js',
'web/static/lib/jSignature/jSignatureCustom.js',
'web/static/src/legacy/js/libs/autocomplete.js',
'web/static/src/legacy/js/libs/bootstrap.js',
'web/static/src/legacy/js/libs/jquery.js',
'web/static/src/legacy/js/libs/jSignatureCustom.js',
'web/static/src/legacy/js/core/bus.js',
'web/static/src/legacy/js/core/class.js',
'web/static/src/legacy/js/core/dialog.js',
@@ -217,11 +215,9 @@ This module provides the core of the Odoo Web Client.
'web/static/lib/bootstrap/js/dist/toast.js',
'web/static/lib/select2/select2.js',
'web/static/lib/clipboard/clipboard.js',
'web/static/lib/jSignature/jSignatureCustom.js',
'web/static/src/legacy/js/libs/autocomplete.js',
'web/static/src/legacy/js/libs/bootstrap.js',
'web/static/src/legacy/js/libs/jquery.js',
'web/static/src/legacy/js/libs/jSignatureCustom.js',
'web/static/src/legacy/js/core/bus.js',
'web/static/src/legacy/js/core/class.js',
'web/static/src/legacy/js/core/dialog.js',
@@ -455,8 +451,9 @@ This module provides the core of the Odoo Web Client.
'web/static/lib/stacktracejs/stacktrace.js',
'web/static/lib/Chart/Chart.js',
'web/static/lib/chartjs-adapter-luxon/chartjs-adapter-luxon.js',
'web/static/lib/jSignature/jSignatureCustom.js',
'web/static/src/libs/jSignatureCustom.js',
# 'web/static/tests/legacy/main_tests.js',
'web/static/tests/helpers/**/*.js',
'web/static/tests/views/helpers.js',
'web/static/tests/search/helpers.js',
@@ -1,5 +1,6 @@
/** @odoo-module **/
import { loadJS } from "@web/core/assets";
import { isMobileOS } from "@web/core/browser/feature_detection";
import { Dropdown } from "@web/core/dropdown/dropdown";
import { DropdownItem } from "@web/core/dropdown/dropdown_item";
@@ -43,6 +44,11 @@ export class NameAndSignature extends Component {
this.fonts = await this.rpc(`/web/sign/get_fonts/${this.props.defaultFont}`);
});
onWillStart(async () => {
await loadJS("/web/static/lib/jSignature/jSignatureCustom.js");
await loadJS("/web/static/src/libs/jSignatureCustom.js");
});
this.signatureRef = useRef("signature");
useEffect(
(el) => {
+3 -3
View File
@@ -3,7 +3,7 @@
import LegacyBus from "@web/legacy/js/core/bus";
import { assets, templates } from "@web/core/assets";
import { browser, makeRAMLocalStorage } from "@web/core/browser/browser";
import { nextTick, patchTimeZone, patchWithCleanup } from "@web/../tests/helpers/utils";
import { patchTimeZone, patchWithCleanup } from "@web/../tests/helpers/utils";
import { memoize } from "@web/core/utils/functions";
import { registerCleanup } from "./helpers/cleanup";
import { prepareRegistriesWithCleanup } from "./helpers/mock_env";
@@ -298,7 +298,7 @@ function patchAssets() {
"%c[assets] fetch (mock) JS ressource: " + ressource,
"color: #66e; font-weight: bold;"
);
return nextTick();
return Promise.resolve();
}
console.log(
"%c[assets] fetch JS ressource: " + ressource,
@@ -312,7 +312,7 @@ function patchAssets() {
"%c[assets] fetch (mock) CSS ressource: " + ressource,
"color: #66e; font-weight: bold;"
);
return nextTick();
return Promise.resolve();
}
console.log(
"%c[assets] fetch CSS ressource: " + ressource,
-2
View File
@@ -76,11 +76,9 @@ Odoo Web Editor widget.
'web/static/lib/bootstrap/js/dist/toast.js',
'web/static/lib/select2/select2.js',
'web/static/lib/clipboard/clipboard.js',
'web/static/lib/jSignature/jSignatureCustom.js',
'web/static/src/legacy/js/libs/autocomplete.js',
'web/static/src/legacy/js/libs/bootstrap.js',
'web/static/src/legacy/js/libs/jquery.js',
'web/static/src/legacy/js/libs/jSignatureCustom.js',
'web/static/src/legacy/js/core/bus.js',
'web/static/src/legacy/js/core/class.js',
'web/static/src/legacy/js/core/dialog.js',
-2
View File
@@ -176,12 +176,10 @@ Featuring
'web/static/lib/bootstrap/js/dist/toast.js',
'web/static/lib/select2/select2.js',
'web/static/lib/clipboard/clipboard.js',
'web/static/lib/jSignature/jSignatureCustom.js',
'web/static/src/legacy/js/libs/autocomplete.js',
'web/static/src/legacy/js/libs/bootstrap.js',
'web/static/src/legacy/js/libs/jquery.js',
'website/static/src/libs/zoomodoo/zoomodoo.js',
'web/static/src/legacy/js/libs/jSignatureCustom.js',
'web/static/src/legacy/js/core/bus.js',
'web/static/src/legacy/js/core/class.js',
'web/static/src/legacy/js/core/dialog.js',