From 562bc47be73b363973c5c85dff1efdc92a418698 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:47:34 +0800 Subject: [PATCH] Revised the saveDescription method of the JournalEntryLineItemEditor editor to also save the isAccountConfirmed status of the DescriptionEditor editor, so that when the user selected any suggested account other than the confirmed account, the confirmed account is released from the next edit. --- src/accounting/static/js/description-editor.js | 14 +++++++------- .../static/js/journal-entry-line-item-editor.js | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/accounting/static/js/description-editor.js b/src/accounting/static/js/description-editor.js index f7f4281..a82c13a 100644 --- a/src/accounting/static/js/description-editor.js +++ b/src/accounting/static/js/description-editor.js @@ -116,7 +116,7 @@ class DescriptionEditor { * Whether the user has confirmed the account * @type {boolean} */ - #isAccountConfirmed = false; + isAccountConfirmed = false; /** * The selected account. @@ -247,7 +247,7 @@ class DescriptionEditor { * @param code {string} the code of the most-frequent suggested account */ #selectSuggestedAccount(code) { - if (this.#isAccountConfirmed) { + if (this.isAccountConfirmed) { return; } for (const account of this.#currentAccountOptions) { @@ -284,7 +284,7 @@ class DescriptionEditor { } this.selectedAccount = selectedAccount; if (this.selectedAccount !== null) { - this.#isAccountConfirmed &&= this.selectedAccount.isConfirmedAccount; + this.isAccountConfirmed &&= this.selectedAccount.isConfirmedAccount; } } @@ -305,7 +305,7 @@ class DescriptionEditor { this.description = this.lineItemEditor.description === null? "": this.lineItemEditor.description; this.#setConfirmedAccount(); this.#onDescriptionChange(); - if (this.#isAccountConfirmed) { + if (this.isAccountConfirmed) { this.selectAccount(this.#confirmedAccount); } } @@ -315,9 +315,9 @@ class DescriptionEditor { * */ #setConfirmedAccount() { - this.#isAccountConfirmed = this.lineItemEditor.isAccountConfirmed; - this.#confirmedAccountPlaceholder.setShown(this.#isAccountConfirmed); - if (this.#isAccountConfirmed) { + this.isAccountConfirmed = this.lineItemEditor.isAccountConfirmed; + this.#confirmedAccountPlaceholder.setShown(this.isAccountConfirmed); + if (this.isAccountConfirmed) { this.#confirmedAccountPlaceholder.initializeFrom(this.lineItemEditor.account); this.#confirmedAccount = this.#confirmedAccountPlaceholder; } else { diff --git a/src/accounting/static/js/journal-entry-line-item-editor.js b/src/accounting/static/js/journal-entry-line-item-editor.js index e3de67d..c154522 100644 --- a/src/accounting/static/js/journal-entry-line-item-editor.js +++ b/src/accounting/static/js/journal-entry-line-item-editor.js @@ -323,6 +323,7 @@ class JournalEntryLineItemEditor { this.#accountControl.classList.add("accounting-not-empty"); this.account = editor.selectedAccount.copy(); this.#accountText.innerText = editor.selectedAccount.text; + this.isAccountConfirmed = editor.isAccountConfirmed; this.#validateAccount(); } if (editor.description === "") {