From 01861f0b6ada4ad71dac6a8437ac575857ce02ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 18 Mar 2023 19:38:04 +0800 Subject: [PATCH] Merged the code in the #initializeAccountSelectors method into the constructor in the JavaScript JournalEntryEditor class. --- .../static/js/journal-entry-editor.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/accounting/static/js/journal-entry-editor.js b/src/accounting/static/js/journal-entry-editor.js index e25f0a1..7e9b544 100644 --- a/src/accounting/static/js/journal-entry-editor.js +++ b/src/accounting/static/js/journal-entry-editor.js @@ -206,7 +206,7 @@ class JournalEntryEditor { * The account selectors * @type {{debit: AccountSelector, credit: AccountSelector}} */ - #accountSelectors; + #accountSelectors = {}; /** * Constructs a new journal entry editor. @@ -231,7 +231,9 @@ class JournalEntryEditor { this.#amount = document.getElementById(this.#prefix + "-amount"); this.#amountError = document.getElementById(this.#prefix + "-amount-error"); this.#summaryEditors = this.#initializeSummaryEditors(); - this.#accountSelectors = this.#initializeAccountSelectors(); + for (const entryType of ["debit", "credit"]) { + this.#accountSelectors[entryType] = new AccountSelector(this, entryType); + } this.#originalEntryControl.onclick = () => OriginalEntrySelector.start(this, this.originalEntryId); this.#originalEntryDelete.onclick = () => this.clearOriginalEntry(); this.#summaryControl.onclick = () => this.#summaryEditors[this.entryType].onOpen(); @@ -265,19 +267,6 @@ class JournalEntryEditor { return editors; } - /** - * Initializes the account selectors. - * - * @return {{debit: AccountSelector, credit: AccountSelector}} the account selectors - */ - #initializeAccountSelectors() { - const selectors = {}; - for (const entryType of ["debit", "credit"]) { - selectors[entryType] = new AccountSelector(this, entryType); - } - return selectors; - } - /** * Saves the original entry from the original entry selector. *