Revised the #initializeSummaryEditors method of the JavaScript JournalEntryEditor class to construct the SummaryEditor instances with the entry type instead of the form element. Replaced the form element with the entry type in the constructor of the SummaryEditor class. Removed the unused accounting-summary-editor class and data-entry-type attributes from the template of the summary editor.
This commit is contained in:
parent
01861f0b6a
commit
35dc513760
@ -259,10 +259,8 @@ class JournalEntryEditor {
|
|||||||
*/
|
*/
|
||||||
#initializeSummaryEditors() {
|
#initializeSummaryEditors() {
|
||||||
const editors = {};
|
const editors = {};
|
||||||
const forms = Array.from(document.getElementsByClassName("accounting-summary-editor"));
|
for (const entryType of ["debit", "credit"]) {
|
||||||
for (const form of forms) {
|
editors[entryType] = new SummaryEditor(this, entryType);
|
||||||
const summaryEditor = new SummaryEditor(this, form);
|
|
||||||
editors[summaryEditor.entryType] = summaryEditor;
|
|
||||||
}
|
}
|
||||||
return editors;
|
return editors;
|
||||||
}
|
}
|
||||||
|
@ -110,13 +110,13 @@ class SummaryEditor {
|
|||||||
* Constructs a summary editor.
|
* Constructs a summary editor.
|
||||||
*
|
*
|
||||||
* @param entryEditor {JournalEntryEditor} the journal entry editor
|
* @param entryEditor {JournalEntryEditor} the journal entry editor
|
||||||
* @param form {HTMLFormElement} the summary editor form
|
* @param entryType {string} the entry type, either "debit" or "credit"
|
||||||
*/
|
*/
|
||||||
constructor(entryEditor, form) {
|
constructor(entryEditor, entryType) {
|
||||||
this.#entryEditor = entryEditor;
|
this.#entryEditor = entryEditor;
|
||||||
this.#form = form;
|
this.entryType = entryType;
|
||||||
this.entryType = form.dataset.entryType;
|
this.prefix = "accounting-summary-editor-" + entryType;
|
||||||
this.prefix = "accounting-summary-editor-" + form.dataset.entryType;
|
this.#form = document.getElementById(this.prefix);
|
||||||
this.#modal = document.getElementById(this.prefix + "-modal");
|
this.#modal = document.getElementById(this.prefix + "-modal");
|
||||||
this.summary = document.getElementById(this.prefix + "-summary");
|
this.summary = document.getElementById(this.prefix + "-summary");
|
||||||
this.#offsetButton = document.getElementById(this.prefix + "-offset");
|
this.#offsetButton = document.getElementById(this.prefix + "-offset");
|
||||||
|
@ -19,7 +19,7 @@ summary-editor-modal.html: The modal of the summary editor
|
|||||||
Author: imacat@mail.imacat.idv.tw (imacat)
|
Author: imacat@mail.imacat.idv.tw (imacat)
|
||||||
First written: 2023/2/28
|
First written: 2023/2/28
|
||||||
#}
|
#}
|
||||||
<form id="accounting-summary-editor-{{ summary_editor.type }}" class="accounting-summary-editor" data-entry-type="{{ summary_editor.type }}">
|
<form id="accounting-summary-editor-{{ summary_editor.type }}">
|
||||||
<div id="accounting-summary-editor-{{ summary_editor.type }}-modal" class="modal fade" tabindex="-1" aria-labelledby="accounting-summary-editor-{{ summary_editor.type }}-modal-label" aria-hidden="true">
|
<div id="accounting-summary-editor-{{ summary_editor.type }}-modal" class="modal fade" tabindex="-1" aria-labelledby="accounting-summary-editor-{{ summary_editor.type }}-modal-label" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
Loading…
Reference in New Issue
Block a user