From 4adc464d3d2cf3d0cf269e21dc0048e38601f8cb 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 09:32:08 +0800 Subject: [PATCH] Merged the saveDescriptionWithAccount into the saveDescription method in the JavaScript JournalEntryLineItemEditor class. --- .../static/js/description-editor.js | 6 +---- .../js/journal-entry-line-item-editor.js | 23 +++++++------------ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/accounting/static/js/description-editor.js b/src/accounting/static/js/description-editor.js index ae9f790..b0a575c 100644 --- a/src/accounting/static/js/description-editor.js +++ b/src/accounting/static/js/description-editor.js @@ -263,11 +263,7 @@ class DescriptionEditor { */ #submit() { bootstrap.Modal.getOrCreateInstance(this.#modal).hide(); - if (this.#selectedAccount !== null) { - this.lineItemEditor.saveDescriptionWithAccount(this.description.value, this.#selectedAccount); - } else { - this.lineItemEditor.saveDescription(this.description.value); - } + this.lineItemEditor.saveDescription(this.description.value, this.#selectedAccount); } /** 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 5afb66b..355172e 100644 --- a/src/accounting/static/js/journal-entry-line-item-editor.js +++ b/src/accounting/static/js/journal-entry-line-item-editor.js @@ -317,8 +317,15 @@ class JournalEntryLineItemEditor { * Saves the description from the description editor. * * @param description {string} the description + * @param account {DescriptionEditorAccount|null} the suggested account */ - saveDescription(description) { + saveDescription(description, account = null) { + if (account !== null) { + this.#accountControl.classList.add("accounting-not-empty"); + this.account = account.copy(); + this.#accountText.innerText = account.text; + this.#validateAccount(); + } if (description === "") { this.#descriptionControl.classList.remove("accounting-not-empty"); } else { @@ -330,20 +337,6 @@ class JournalEntryLineItemEditor { bootstrap.Modal.getOrCreateInstance(this.modal).show(); } - /** - * Saves the description with the suggested account from the description editor. - * - * @param description {string} the description - * @param account {DescriptionEditorAccount} the suggested account - */ - saveDescriptionWithAccount(description, account) { - this.#accountControl.classList.add("accounting-not-empty"); - this.account = account.copy(); - this.#accountText.innerText = account.text; - this.#validateAccount(); - this.saveDescription(description) - } - /** * Clears the account. *