From 7c3b8c8f444309a4e27168225a2807fb95c4024e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Wed, 8 Mar 2023 14:22:29 +0800 Subject: [PATCH] Revised to store the newly-constructed period chooser and month chooser in variables to prevent SonarQube from complaining. --- src/accounting/static/js/period-chooser.js | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/accounting/static/js/period-chooser.js b/src/accounting/static/js/period-chooser.js index faa4f8f..b84061a 100644 --- a/src/accounting/static/js/period-chooser.js +++ b/src/accounting/static/js/period-chooser.js @@ -24,7 +24,7 @@ // Initializes the page JavaScript. document.addEventListener("DOMContentLoaded", () => { - new PeriodChooser(); + PeriodChooser.initialize(); }); /** @@ -63,6 +63,20 @@ class PeriodChooser { this.tabPlanes[tab.tabId()] = tab; } } + + /** + * The period chooser. + * @type {PeriodChooser} + */ + static #chooser; + + /** + * Initializes the period chooser. + * + */ + static initialize() { + this.#chooser = new PeriodChooser(); + } } /** @@ -143,6 +157,12 @@ class TabPlane { */ class MonthTab extends TabPlane { + /** + * The month chooser. + * @type {tempusDominus.TempusDominus} + */ + #monthChooser + /** * Constructs a tab plane. * @@ -152,7 +172,7 @@ class MonthTab extends TabPlane { super(chooser); const monthChooser = document.getElementById(this.prefix + "-chooser"); let start = monthChooser.dataset.start; - new tempusDominus.TempusDominus(monthChooser, { + this.#monthChooser = new tempusDominus.TempusDominus(monthChooser, { restrictions: { minDate: start, },