Revised the JavaScript DebitCreditSubForm to have a better visual effect when the line item editor is opened and closed with no line items.

This commit is contained in:
依瑪貓 2023-03-24 07:58:32 +08:00
parent dc432da398
commit 7c512b1c15
2 changed files with 15 additions and 1 deletions

View File

@ -631,6 +631,16 @@ class DebitCreditSubForm {
this.#initializeDragAndDropReordering();
}
/**
* The callback when the line item editor is closed.
*
*/
onLineItemEditorClosed() {
if (this.lineItems.length === 0) {
this.#element.classList.remove("accounting-not-empty");
}
}
/**
* Adds a new line item sub-form
*
@ -691,7 +701,10 @@ class DebitCreditSubForm {
this.#element.classList.add("accounting-clickable");
this.#element.dataset.bsToggle = "modal"
this.#element.dataset.bsTarget = "#" + this.currency.form.lineItemEditor.modal.id;
this.#element.onclick = () => this.currency.form.lineItemEditor.onAddNew(this);
this.#element.onclick = () => {
this.#element.classList.add("accounting-not-empty");
this.currency.form.lineItemEditor.onAddNew(this);
};
this.#content.classList.add("d-none");
} else {
this.#element.classList.add("accounting-not-empty");

View File

@ -249,6 +249,7 @@ class JournalEntryLineItemEditor {
}
return false;
};
this.modal.addEventListener("hidden.bs.modal", () => this.#debitCreditSubForm.onLineItemEditorClosed());
}
/**