Added the JavaScript getInstances method to the SummaryEditor and AccountSelector classes, so that it is easier to deal with the case when the debit and credit versions are not both exist.

This commit is contained in:
2023-03-18 23:36:38 +08:00
parent a2311aee24
commit 6d293a1aac
5 changed files with 36 additions and 10 deletions

View File

@ -206,4 +206,19 @@ class AccountSelector {
this.#clearButton.disabled = false;
}
}
/**
* Returns the account selector instances.
*
* @param entryEditor {JournalEntryEditor} the journal entry editor
* @return {{debit: AccountSelector, credit: AccountSelector}}
*/
static getInstances(entryEditor) {
const selectors = {}
const modals = Array.from(document.getElementsByClassName("accounting-account-selector"));
for (const modal of modals) {
selectors[modal.dataset.entryType] = new AccountSelector(entryEditor, modal.dataset.entryType);
}
return selectors;
}
}