diff --git a/src/accounting/static/js/description-editor.js b/src/accounting/static/js/description-editor.js index f08185a..42301b7 100644 --- a/src/accounting/static/js/description-editor.js +++ b/src/accounting/static/js/description-editor.js @@ -122,7 +122,7 @@ class DescriptionEditor { * The selected account. * @type {DescriptionEditorAccount|null} */ - #selectedAccount = null; + selectedAccount = null; /** * The tab planes @@ -200,7 +200,7 @@ class DescriptionEditor { */ #onDescriptionChange() { this.#resetTabPlanes(); - this.#selectedAccount = null; + this.selectedAccount = null; this.description = this.description.trim(); for (const tabPlane of [this.tabPlanes.recurring, this.tabPlanes.bus, this.tabPlanes.travel, this.tabPlanes.general]) { if (tabPlane.populate()) { @@ -282,9 +282,9 @@ class DescriptionEditor { if (selectedAccount !== null) { selectedAccount.setActive(true); } - this.#selectedAccount = selectedAccount; - if (this.#selectedAccount !== null) { - this.#isAccountConfirmed &= this.#selectedAccount.isConfirmedAccount; + this.selectedAccount = selectedAccount; + if (this.selectedAccount !== null) { + this.#isAccountConfirmed &= this.selectedAccount.isConfirmedAccount; } } @@ -294,7 +294,7 @@ class DescriptionEditor { */ #submit() { bootstrap.Modal.getOrCreateInstance(this.#modal).hide(); - this.lineItemEditor.saveDescription(this.description, this.#selectedAccount); + this.lineItemEditor.saveDescription(this); } /** 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 355172e..e3de67d 100644 --- a/src/accounting/static/js/journal-entry-line-item-editor.js +++ b/src/accounting/static/js/journal-entry-line-item-editor.js @@ -316,23 +316,22 @@ class JournalEntryLineItemEditor { /** * Saves the description from the description editor. * - * @param description {string} the description - * @param account {DescriptionEditorAccount|null} the suggested account + * @param editor {DescriptionEditor} the description editor */ - saveDescription(description, account = null) { - if (account !== null) { + saveDescription(editor) { + if (editor.selectedAccount !== null) { this.#accountControl.classList.add("accounting-not-empty"); - this.account = account.copy(); - this.#accountText.innerText = account.text; + this.account = editor.selectedAccount.copy(); + this.#accountText.innerText = editor.selectedAccount.text; this.#validateAccount(); } - if (description === "") { + if (editor.description === "") { this.#descriptionControl.classList.remove("accounting-not-empty"); } else { this.#descriptionControl.classList.add("accounting-not-empty"); } - this.description = description === ""? null: description; - this.#descriptionText.innerText = description; + this.description = editor.description === ""? null: editor.description; + this.#descriptionText.innerText = editor.description; this.#validateDescription(); bootstrap.Modal.getOrCreateInstance(this.modal).show(); }