Revised the coding style with the JavaScript arrow functions for the transaction form.

This commit is contained in:
依瑪貓 2023-03-18 17:15:51 +08:00
parent fbeec600b7
commit be10a8d99e
3 changed files with 9 additions and 27 deletions

View File

@ -106,13 +106,9 @@ class AccountSelector {
this.#more.classList.add("d-none");
this.#filterOptions();
};
this.#clearButton.onclick = () => {
this.#entryEditor.clearAccount();
};
this.#clearButton.onclick = () => this.#entryEditor.clearAccount();
for (const option of this.#options) {
option.onclick = () => {
this.#entryEditor.saveAccount(option.dataset.code, option.dataset.content, option.classList.contains("accounting-account-is-offset-needed"));
};
option.onclick = () => this.#entryEditor.saveAccount(option.dataset.code, option.dataset.content, option.classList.contains("accounting-account-is-offset-needed"));
}
this.#query.addEventListener("input", () => {
this.#filterOptions();

View File

@ -218,12 +218,8 @@ class JournalEntryEditor {
this.#originalEntryControl.onclick = () => OriginalEntrySelector.start(this, this.originalEntryId);
this.#originalEntryDelete.onclick = () => this.clearOriginalEntry();
this.#summaryControl.onclick = () => SummaryEditor.start(this, this.summary);
this.#accountControl.onclick = () => {
AccountSelector.start(this, this.entryType);
}
this.#amount.onchange = () => {
this.#validateAmount();
}
this.#accountControl.onclick = () => AccountSelector.start(this, this.entryType);
this.#amount.onchange = () => this.#validateAmount();
this.#element.onsubmit = () => {
if (this.#validate()) {
if (this.entry === null) {

View File

@ -128,12 +128,8 @@ class TransactionForm {
};
this.#resetDeleteCurrencyButtons();
this.#initializeDragAndDropReordering();
this.#date.onchange = () => {
this.#validateDate();
};
this.#note.onchange = () => {
this.#validateNote();
}
this.#date.onchange = () => this.#validateDate();
this.#note.onchange = () => this.#validateNote();
this.#element.onsubmit = () => {
return this.#validate();
};
@ -435,9 +431,7 @@ class CurrencySubForm {
this.#debit = debitElement === null? null: new DebitCreditSideSubForm(this, debitElement, "debit");
const creditElement = document.getElementById(this.#prefix + "-credit");
this.#credit = creditElement == null? null: new DebitCreditSideSubForm(this, creditElement, "credit");
this.#codeSelect.onchange = () => {
this.#code.value = this.#codeSelect.value;
};
this.#codeSelect.onchange = () => this.#code.value = this.#codeSelect.value;
this.deleteButton.onclick = () => {
this.element.parentElement.removeChild(this.element);
this.form.deleteCurrency(this);
@ -607,9 +601,7 @@ class DebitCreditSideSubForm {
this.entries = Array.from(document.getElementsByClassName(this.#prefix)).map((element) => new JournalEntrySubForm(this, element));
this.#total = document.getElementById(this.#prefix + "-total");
this.#addEntryButton = document.getElementById(this.#prefix + "-add-entry");
this.#addEntryButton.onclick = () => {
JournalEntryEditor.addNew(this);
};
this.#addEntryButton.onclick = () => JournalEntryEditor.addNew(this);
this.#resetDeleteJournalEntryButtons();
this.#initializeDragAndDropReordering();
}
@ -882,9 +874,7 @@ class JournalEntrySubForm {
this.#amount = document.getElementById(this.#prefix + "-amount");
this.#amountText = document.getElementById(this.#prefix + "-amount-text");
this.deleteButton = document.getElementById(this.#prefix + "-delete");
this.#control.onclick = () => {
JournalEntryEditor.edit(this, this.#originalEntryId.value, this.#originalEntryId.dataset.date, this.#originalEntryId.dataset.text, this.#summary.value, this.#accountCode.value, this.#accountCode.dataset.text, this.#amount.value, this.#amount.dataset.min);
};
this.#control.onclick = () => JournalEntryEditor.edit(this, this.#originalEntryId.value, this.#originalEntryId.dataset.date, this.#originalEntryId.dataset.text, this.#summary.value, this.#accountCode.value, this.#accountCode.dataset.text, this.#amount.value, this.#amount.dataset.min);
this.deleteButton.onclick = () => {
this.element.parentElement.removeChild(this.element);
this.side.deleteJournalEntry(this);