Replaces the datasets with object attributes to store the currency code and entry type in the JavaScript OriginalEntrySelector class.

This commit is contained in:
依瑪貓 2023-03-18 22:00:01 +08:00
parent 4a8297d594
commit ca928636fd
2 changed files with 15 additions and 4 deletions

View File

@ -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);
}

View File

@ -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
#}
<div id="accounting-original-entry-selector-modal" class="modal fade" data-currency-code="" data-entry-type="" tabindex="-1" aria-labelledby="accounting-original-entry-selector-modal-label" aria-hidden="true">
<div id="accounting-original-entry-selector-modal" class="modal fade" tabindex="-1" aria-labelledby="accounting-original-entry-selector-modal-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">