Added prefix to the constructor of the BaseAccountSelector class, to simplify the code.

This commit is contained in:
依瑪貓 2023-03-24 00:37:59 +08:00
parent 821059fa80
commit 0130bc58a9

View File

@ -269,12 +269,13 @@ class BaseAccountSelector {
*/ */
constructor(form) { constructor(form) {
this.form = form; this.form = form;
this.#modal = document.getElementById("accounting-base-selector-modal"); const prefix = "accounting-base-selector";
this.#query = document.getElementById("accounting-base-selector-query"); this.#modal = document.getElementById(`${prefix}-modal`);
this.#queryNoResult = document.getElementById("accounting-base-selector-option-no-result"); this.#query = document.getElementById(`${prefix}-query`);
this.#optionList = document.getElementById("accounting-base-selector-option-list"); this.#queryNoResult = document.getElementById(`${prefix}-option-no-result`);
this.#options = Array.from(document.getElementsByClassName("accounting-base-selector-option")).map((element) => new BaseAccountOption(this, element)); this.#optionList = document.getElementById(`${prefix}-option-list`);
this.#clearButton = document.getElementById("accounting-base-selector-clear"); this.#options = Array.from(document.getElementsByClassName(`${prefix}-option`)).map((element) => new BaseAccountOption(this, element));
this.#clearButton = document.getElementById(`${prefix}-clear`);
this.#modal.addEventListener("hidden.bs.modal", () => this.form.onBaseAccountSelectorClosed()); this.#modal.addEventListener("hidden.bs.modal", () => this.form.onBaseAccountSelectorClosed());
this.#query.oninput = () => this.#filterOptions(); this.#query.oninput = () => this.#filterOptions();