From 0130bc58a9111cca66befe1917d9ca73f154c0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Fri, 24 Mar 2023 00:37:59 +0800 Subject: [PATCH] Added prefix to the constructor of the BaseAccountSelector class, to simplify the code. --- src/accounting/static/js/account-form.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/accounting/static/js/account-form.js b/src/accounting/static/js/account-form.js index 1fc98f0..535e4ea 100644 --- a/src/accounting/static/js/account-form.js +++ b/src/accounting/static/js/account-form.js @@ -269,12 +269,13 @@ class BaseAccountSelector { */ constructor(form) { this.form = form; - this.#modal = document.getElementById("accounting-base-selector-modal"); - this.#query = document.getElementById("accounting-base-selector-query"); - this.#queryNoResult = document.getElementById("accounting-base-selector-option-no-result"); - this.#optionList = document.getElementById("accounting-base-selector-option-list"); - this.#options = Array.from(document.getElementsByClassName("accounting-base-selector-option")).map((element) => new BaseAccountOption(this, element)); - this.#clearButton = document.getElementById("accounting-base-selector-clear"); + const prefix = "accounting-base-selector"; + this.#modal = document.getElementById(`${prefix}-modal`); + 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 BaseAccountOption(this, element)); + this.#clearButton = document.getElementById(`${prefix}-clear`); this.#modal.addEventListener("hidden.bs.modal", () => this.form.onBaseAccountSelectorClosed()); this.#query.oninput = () => this.#filterOptions();