Renamed the JavaScript AccountSelector class to JournalEntryAccountSelector, to avoid confusion. There is a RecurringAccountSelector in the option form now.

This commit is contained in:
依瑪貓 2023-03-24 07:27:01 +08:00
parent eb5a7bef7e
commit 30e0c7682c
3 changed files with 13 additions and 13 deletions

View File

@ -1,5 +1,5 @@
/* The Mia! Accounting Flask Project
* account-selector.js: The JavaScript for the account selector
* journal-entry-account-selector.js: The JavaScript for the account selector of the journal entry form
*/
/* Copyright (c) 2023 imacat.
@ -26,7 +26,7 @@
* The account selector.
*
*/
class AccountSelector {
class JournalEntryAccountSelector {
/**
* The line item editor
@ -66,7 +66,7 @@ class AccountSelector {
/**
* The options
* @type {AccountOption[]}
* @type {JournalEntryAccountOption[]}
*/
#options;
@ -95,7 +95,7 @@ class AccountSelector {
this.#query = document.getElementById(prefix + "-query");
this.#queryNoResult = document.getElementById(prefix + "-option-no-result");
this.#optionList = document.getElementById(prefix + "-option-list");
this.#options = Array.from(document.getElementsByClassName(prefix + "-option")).map((element) => new AccountOption(this, element));
this.#options = Array.from(document.getElementsByClassName(prefix + "-option")).map((element) => new JournalEntryAccountOption(this, element));
this.#more = document.getElementById(prefix + "-more");
this.#clearButton = document.getElementById(prefix + "-btn-clear");
@ -172,13 +172,13 @@ class AccountSelector {
* Returns the account selector instances.
*
* @param lineItemEditor {JournalEntryLineItemEditor} the line item editor
* @return {{debit: AccountSelector, credit: AccountSelector}}
* @return {{debit: JournalEntryAccountSelector, credit: JournalEntryAccountSelector}}
*/
static getInstances(lineItemEditor) {
const selectors = {}
const modals = Array.from(document.getElementsByClassName("accounting-account-selector"));
for (const modal of modals) {
selectors[modal.dataset.debitCredit] = new AccountSelector(lineItemEditor, modal.dataset.debitCredit);
selectors[modal.dataset.debitCredit] = new JournalEntryAccountSelector(lineItemEditor, modal.dataset.debitCredit);
}
return selectors;
}
@ -188,11 +188,11 @@ class AccountSelector {
* An account option
*
*/
class AccountOption {
class JournalEntryAccountOption {
/**
* The account selector
* @type {AccountSelector}
* @type {JournalEntryAccountSelector}
*/
#selector;
@ -235,7 +235,7 @@ class AccountOption {
/**
* Constructs the account in the account selector.
*
* @param selector {AccountSelector} the account selector
* @param selector {JournalEntryAccountSelector} the account selector
* @param element {HTMLLIElement} the element
*/
constructor(selector, element) {

View File

@ -198,7 +198,7 @@ class JournalEntryLineItemEditor {
/**
* The account selectors
* @type {{debit: AccountSelector, credit: AccountSelector}}
* @type {{debit: JournalEntryAccountSelector, credit: JournalEntryAccountSelector}}
*/
#accountSelectors;
@ -231,7 +231,7 @@ class JournalEntryLineItemEditor {
this.#amountInput = document.getElementById(this.#prefix + "-amount");
this.#amountError = document.getElementById(this.#prefix + "-amount-error");
this.#descriptionEditors = DescriptionEditor.getInstances(this);
this.#accountSelectors = AccountSelector.getInstances(this);
this.#accountSelectors = JournalEntryAccountSelector.getInstances(this);
this.originalLineItemSelector = new OriginalLineItemSelector(this);
this.#originalLineItemControl.onclick = () => this.originalLineItemSelector.onOpen()
this.#originalLineItemDelete.onclick = () => this.clearOriginalLineItem();
@ -370,7 +370,7 @@ class JournalEntryLineItemEditor {
/**
* Saves the selected account.
*
* @param account {AccountOption} the selected account
* @param account {JournalEntryAccountOption} the selected account
*/
saveAccount(account) {
this.isNeedOffset = account.isNeedOffset;

View File

@ -25,7 +25,7 @@ First written: 2023/2/26
<script src="{{ url_for("accounting.static", filename="js/drag-and-drop-reorder.js") }}"></script>
<script src="{{ url_for("accounting.static", filename="js/journal-entry-form.js") }}"></script>
<script src="{{ url_for("accounting.static", filename="js/journal-entry-line-item-editor.js") }}"></script>
<script src="{{ url_for("accounting.static", filename="js/account-selector.js") }}"></script>
<script src="{{ url_for("accounting.static", filename="js/journal-entry-account-selector.js") }}"></script>
<script src="{{ url_for("accounting.static", filename="js/original-line-item-selector.js") }}"></script>
<script src="{{ url_for("accounting.static", filename="js/description-editor.js") }}"></script>
{% endblock %}