From ca928636fd5759e0e0dbcf8903abc9717a774fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 18 Mar 2023 22:00:01 +0800 Subject: [PATCH] Replaces the datasets with object attributes to store the currency code and entry type in the JavaScript OriginalEntrySelector class. --- .../static/js/original-entry-selector.js | 17 ++++++++++++++--- .../include/original-entry-selector-modal.html | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/accounting/static/js/original-entry-selector.js b/src/accounting/static/js/original-entry-selector.js index bd4c3d2..24b8a7b 100644 --- a/src/accounting/static/js/original-entry-selector.js +++ b/src/accounting/static/js/original-entry-selector.js @@ -76,6 +76,17 @@ class OriginalEntrySelector { */ entryEditor; + /** + * The currency code + * @type {string} + */ + #currencyCode; + + /** + * The entry + */ + #entryType; + /** * Constructs an original entry selector. * @@ -151,7 +162,7 @@ class OriginalEntrySelector { #filterOptions() { let hasAnyMatched = false; for (const option of this.#options) { - if (option.isMatched(this.#modal.dataset.entryType, this.#modal.dataset.currencyCode, this.#query.value)) { + if (option.isMatched(this.#entryType, this.#currencyCode, this.#query.value)) { option.setShown(true); hasAnyMatched = true; } else { @@ -175,8 +186,8 @@ class OriginalEntrySelector { */ onOpen(entryEditor, originalEntryId = null) { this.entryEditor = entryEditor - this.#modal.dataset.currencyCode = entryEditor.getCurrencyCode(); - this.#modal.dataset.entryType = entryEditor.entryType; + this.#currencyCode = entryEditor.getCurrencyCode(); + this.#entryType = entryEditor.entryType; for (const option of this.#options) { option.setActive(option.id === originalEntryId); } diff --git a/src/accounting/templates/accounting/transaction/include/original-entry-selector-modal.html b/src/accounting/templates/accounting/transaction/include/original-entry-selector-modal.html index 0646559..74160ea 100644 --- a/src/accounting/templates/accounting/transaction/include/original-entry-selector-modal.html +++ b/src/accounting/templates/accounting/transaction/include/original-entry-selector-modal.html @@ -19,7 +19,7 @@ original-entry-selector-modal.html: The modal of the original entry selector Author: imacat@mail.imacat.idv.tw (imacat) First written: 2023/2/25 #} -