Merged the code in the #initializeAccountSelectors method into the constructor in the JavaScript JournalEntryEditor class.

This commit is contained in:
依瑪貓 2023-03-18 19:38:04 +08:00
parent 8c10f1e96a
commit 01861f0b6a

View File

@ -206,7 +206,7 @@ class JournalEntryEditor {
* The account selectors * The account selectors
* @type {{debit: AccountSelector, credit: AccountSelector}} * @type {{debit: AccountSelector, credit: AccountSelector}}
*/ */
#accountSelectors; #accountSelectors = {};
/** /**
* Constructs a new journal entry editor. * Constructs a new journal entry editor.
@ -231,7 +231,9 @@ class JournalEntryEditor {
this.#amount = document.getElementById(this.#prefix + "-amount"); this.#amount = document.getElementById(this.#prefix + "-amount");
this.#amountError = document.getElementById(this.#prefix + "-amount-error"); this.#amountError = document.getElementById(this.#prefix + "-amount-error");
this.#summaryEditors = this.#initializeSummaryEditors(); 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.#originalEntryControl.onclick = () => OriginalEntrySelector.start(this, this.originalEntryId);
this.#originalEntryDelete.onclick = () => this.clearOriginalEntry(); this.#originalEntryDelete.onclick = () => this.clearOriginalEntry();
this.#summaryControl.onclick = () => this.#summaryEditors[this.entryType].onOpen(); this.#summaryControl.onclick = () => this.#summaryEditors[this.entryType].onOpen();
@ -265,19 +267,6 @@ class JournalEntryEditor {
return editors; 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. * Saves the original entry from the original entry selector.
* *