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.#more.classList.add("d-none");
this.#filterOptions(); this.#filterOptions();
}; };
this.#clearButton.onclick = () => { this.#clearButton.onclick = () => this.#entryEditor.clearAccount();
this.#entryEditor.clearAccount();
};
for (const option of this.#options) { for (const option of this.#options) {
option.onclick = () => { option.onclick = () => this.#entryEditor.saveAccount(option.dataset.code, option.dataset.content, option.classList.contains("accounting-account-is-offset-needed"));
this.#entryEditor.saveAccount(option.dataset.code, option.dataset.content, option.classList.contains("accounting-account-is-offset-needed"));
};
} }
this.#query.addEventListener("input", () => { this.#query.addEventListener("input", () => {
this.#filterOptions(); this.#filterOptions();

View File

@ -218,12 +218,8 @@ class JournalEntryEditor {
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 = () => SummaryEditor.start(this, this.summary); this.#summaryControl.onclick = () => SummaryEditor.start(this, this.summary);
this.#accountControl.onclick = () => { this.#accountControl.onclick = () => AccountSelector.start(this, this.entryType);
AccountSelector.start(this, this.entryType); this.#amount.onchange = () => this.#validateAmount();
}
this.#amount.onchange = () => {
this.#validateAmount();
}
this.#element.onsubmit = () => { this.#element.onsubmit = () => {
if (this.#validate()) { if (this.#validate()) {
if (this.entry === null) { if (this.entry === null) {

View File

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