Skip to content
Extraits de code Groupes Projets
Valider e0aabf07 rédigé par Rémi - Le Filament's avatar Rémi - Le Filament
Parcourir les fichiers

[UPD] avoid loading mutliple time js libraries

parent c04236ce
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -20,10 +20,7 @@ ...@@ -20,10 +20,7 @@
"assets": { "assets": {
"web.assets_frontend": [ "web.assets_frontend": [
"oacc_portal_overview_cdc/static/src/css/style.css", "oacc_portal_overview_cdc/static/src/css/style.css",
"web/static/lib/Chart/Chart.js", "oacc_portal_overview_cdc/static/src/js/operation_chart.js",
"oacc_portal_overview_cdc/static/lib/daterangepicker/daterangepicker.js",
"oacc_portal_overview_cdc/static/src/js/lib/chartjs-plugin-datalabels.min.js",
"oacc_portal_overview_cdc/static/src/js/canvas.js",
"oacc_portal_overview_cdc/static/src/js/select2_fr.js", "oacc_portal_overview_cdc/static/src/js/select2_fr.js",
], ],
}, },
......
...@@ -2,17 +2,14 @@ ...@@ -2,17 +2,14 @@
* @copyright: 2023- Le Filament (<https://le-filament.com>) * @copyright: 2023- Le Filament (<https://le-filament.com>)
* @license: AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). * @license: AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
*/ */
odoo.define("oacc_portal_overview_cdc.canvas", function (require) { odoo.define("oacc_portal_overview_cdc.operation_chart", function (require) {
"use strict"; "use strict";
const { loadJS } = require("@web/core/assets");
var publicWidget = require("web.public.widget"); var publicWidget = require("web.public.widget");
publicWidget.registry.oaccPortalOverviewCdc = publicWidget.Widget.extend({ publicWidget.registry.OaccOperationChart = publicWidget.Widget.extend({
jsLibs: [ selector: ".operation_chart",
"/web/static/lib/Chart/Chart.js",
"/oacc_portal_overview_cdc/static/src/js/lib/chartjs-plugin-datalabels.min.js",
],
selector: ".oe_website_canvas",
events: { events: {
"click .btn-period": "_onBtnPeriodClick", "click .btn-period": "_onBtnPeriodClick",
"click #previous-period": "_onPreviousPeriod", "click #previous-period": "_onPreviousPeriod",
...@@ -26,7 +23,7 @@ odoo.define("oacc_portal_overview_cdc.canvas", function (require) { ...@@ -26,7 +23,7 @@ odoo.define("oacc_portal_overview_cdc.canvas", function (require) {
init: function () { init: function () {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.operation = $(".oe_website_canvas").data("id"); this.operation = $(".operation_chart").data("id");
this.scale = null; this.scale = null;
this.minDate = null; this.minDate = null;
...@@ -65,6 +62,17 @@ odoo.define("oacc_portal_overview_cdc.canvas", function (require) { ...@@ -65,6 +62,17 @@ odoo.define("oacc_portal_overview_cdc.canvas", function (require) {
}); });
return Promise.all([this._super.apply(this, arguments), def]); return Promise.all([this._super.apply(this, arguments), def]);
}, },
willStart: async function () {
await loadJS("/web/static/lib/Chart/Chart.js");
await loadJS(
"/oacc_portal_overview_cdc/static/src/js/lib/chartjs-plugin-datalabels.min.js"
);
await loadJS(
"/oacc_portal_overview_cdc/static/lib/daterangepicker/daterangepicker.js"
);
},
/** /**
* @override * @override
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<t t-call="oacc_portal.layout_op"> <t t-call="oacc_portal.layout_op">
<t t-set="type_data" t-value="'pmo'" /> <t t-set="type_data" t-value="'pmo'" />
<div <div
class="oe_website_canvas mb-5" class="operation_chart mb-5"
t-att-data-name="type_data" t-att-data-name="type_data"
t-att-data-id="operation.id" t-att-data-id="operation.id"
> >
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<t t-call="oacc_portal.layout_op"> <t t-call="oacc_portal.layout_op">
<t t-set="type_data" t-value="'cons'" /> <t t-set="type_data" t-value="'cons'" />
<div <div
class="mb-5 oe_website_canvas" class="operation_chart mb-5"
t-att-data-name="type_data" t-att-data-name="type_data"
t-att-data-id="operation.id" t-att-data-id="operation.id"
> >
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<t t-call="oacc_portal.layout_op"> <t t-call="oacc_portal.layout_op">
<t t-set="type_data" t-value="'prod'" /> <t t-set="type_data" t-value="'prod'" />
<div <div
class="mb-5 oe_website_canvas" class="operation_chart mb-5"
t-att-data-name="type_data" t-att-data-name="type_data"
t-att-data-id="operation.id" t-att-data-id="operation.id"
> >
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter