From 8033921181e3a03d5c7f68d3cab6b8c384c8f06a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Mon, 3 Apr 2023 10:06:19 +0800 Subject: [PATCH] Revised the JavaScript DescriptionEditor class so that the #reset() method is triggered by the #onDescriptionChange event, but not the onOpen event, so that user-edited description updates also clear the tab planes. --- .../static/js/description-editor.js | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/accounting/static/js/description-editor.js b/src/accounting/static/js/description-editor.js index fdc99be..2340f8c 100644 --- a/src/accounting/static/js/description-editor.js +++ b/src/accounting/static/js/description-editor.js @@ -199,6 +199,7 @@ class DescriptionEditor { * */ #onDescriptionChange() { + this.#reset(); this.description = this.description.trim(); for (const tabPlane of [this.tabPlanes.recurring, this.tabPlanes.bus, this.tabPlanes.travel, this.tabPlanes.general]) { if (tabPlane.populate()) { @@ -208,6 +209,17 @@ class DescriptionEditor { this.tabPlanes.annotation.populate(); } + /** + * Resets the description editor. + * + */ + #reset() { + for (const tabPlane of Object.values(this.tabPlanes)) { + tabPlane.reset(); + } + this.tabPlanes.general.switchToMe(); + } + /** * Updates the current suggested accounts. * @@ -289,10 +301,9 @@ class DescriptionEditor { * */ onOpen() { - this.#reset(); - this.#setConfirmedAccount(); this.description = this.lineItemEditor.description === null? "": this.lineItemEditor.description; this.#onDescriptionChange(); + this.#setConfirmedAccount(); } /** @@ -311,18 +322,6 @@ class DescriptionEditor { this.selectAccount(this.#confirmedAccount); } - /** - * Resets the description editor. - * - */ - #reset() { - this.description = ""; - for (const tabPlane of Object.values(this.tabPlanes)) { - tabPlane.reset(); - } - this.tabPlanes.general.switchToMe(); - } - /** * Returns the description editor instances. *