Revised the saveDescription method of the JavaScript JournalEntryLineItemEditor to accept the description editor instead of the separated description and account values.
This commit is contained in:
parent
f2a2fcdd32
commit
e1a0380628
@ -122,7 +122,7 @@ class DescriptionEditor {
|
||||
* The selected account.
|
||||
* @type {DescriptionEditorAccount|null}
|
||||
*/
|
||||
#selectedAccount = null;
|
||||
selectedAccount = null;
|
||||
|
||||
/**
|
||||
* The tab planes
|
||||
@ -200,7 +200,7 @@ class DescriptionEditor {
|
||||
*/
|
||||
#onDescriptionChange() {
|
||||
this.#resetTabPlanes();
|
||||
this.#selectedAccount = null;
|
||||
this.selectedAccount = null;
|
||||
this.description = this.description.trim();
|
||||
for (const tabPlane of [this.tabPlanes.recurring, this.tabPlanes.bus, this.tabPlanes.travel, this.tabPlanes.general]) {
|
||||
if (tabPlane.populate()) {
|
||||
@ -282,9 +282,9 @@ class DescriptionEditor {
|
||||
if (selectedAccount !== null) {
|
||||
selectedAccount.setActive(true);
|
||||
}
|
||||
this.#selectedAccount = selectedAccount;
|
||||
if (this.#selectedAccount !== null) {
|
||||
this.#isAccountConfirmed &= this.#selectedAccount.isConfirmedAccount;
|
||||
this.selectedAccount = selectedAccount;
|
||||
if (this.selectedAccount !== null) {
|
||||
this.#isAccountConfirmed &= this.selectedAccount.isConfirmedAccount;
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ class DescriptionEditor {
|
||||
*/
|
||||
#submit() {
|
||||
bootstrap.Modal.getOrCreateInstance(this.#modal).hide();
|
||||
this.lineItemEditor.saveDescription(this.description, this.#selectedAccount);
|
||||
this.lineItemEditor.saveDescription(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -316,23 +316,22 @@ class JournalEntryLineItemEditor {
|
||||
/**
|
||||
* Saves the description from the description editor.
|
||||
*
|
||||
* @param description {string} the description
|
||||
* @param account {DescriptionEditorAccount|null} the suggested account
|
||||
* @param editor {DescriptionEditor} the description editor
|
||||
*/
|
||||
saveDescription(description, account = null) {
|
||||
if (account !== null) {
|
||||
saveDescription(editor) {
|
||||
if (editor.selectedAccount !== null) {
|
||||
this.#accountControl.classList.add("accounting-not-empty");
|
||||
this.account = account.copy();
|
||||
this.#accountText.innerText = account.text;
|
||||
this.account = editor.selectedAccount.copy();
|
||||
this.#accountText.innerText = editor.selectedAccount.text;
|
||||
this.#validateAccount();
|
||||
}
|
||||
if (description === "") {
|
||||
if (editor.description === "") {
|
||||
this.#descriptionControl.classList.remove("accounting-not-empty");
|
||||
} else {
|
||||
this.#descriptionControl.classList.add("accounting-not-empty");
|
||||
}
|
||||
this.description = description === ""? null: description;
|
||||
this.#descriptionText.innerText = description;
|
||||
this.description = editor.description === ""? null: editor.description;
|
||||
this.#descriptionText.innerText = editor.description;
|
||||
this.#validateDescription();
|
||||
bootstrap.Modal.getOrCreateInstance(this.modal).show();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user