Replaced the #populate method with the #parseAndPopulate method that is used both when starting the summary helper and when the summary input is updated.
This commit is contained in:
parent
453b3f0da5
commit
b2bc993416
@ -68,6 +68,7 @@ class SummaryHelper {
|
|||||||
*/
|
*/
|
||||||
#init() {
|
#init() {
|
||||||
const helper = this;
|
const helper = this;
|
||||||
|
const summary = document.getElementById(this.#prefix + "-summary");
|
||||||
const tabs = Array.from(document.getElementsByClassName(this.#prefix + "-tab"));
|
const tabs = Array.from(document.getElementsByClassName(this.#prefix + "-tab"));
|
||||||
for (const tab of tabs) {
|
for (const tab of tabs) {
|
||||||
tab.onclick = function () {
|
tab.onclick = function () {
|
||||||
@ -80,6 +81,10 @@ class SummaryHelper {
|
|||||||
this.#initializeNumberHelper();
|
this.#initializeNumberHelper();
|
||||||
this.#initializeSuggestedAccounts();
|
this.#initializeSuggestedAccounts();
|
||||||
this.#initializeSubmission();
|
this.#initializeSubmission();
|
||||||
|
summary.onchange = function () {
|
||||||
|
summary.value = summary.value.trim();
|
||||||
|
helper.#parseAndPopulate();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -610,6 +615,8 @@ class SummaryHelper {
|
|||||||
* @param isNew {boolean} true for adding a new journal entry, or false otherwise
|
* @param isNew {boolean} true for adding a new journal entry, or false otherwise
|
||||||
*/
|
*/
|
||||||
initShow(isNew) {
|
initShow(isNew) {
|
||||||
|
const formSummary = document.getElementById("accounting-entry-form-summary");
|
||||||
|
const summary = document.getElementById(this.#prefix + "-summary");
|
||||||
const closeButtons = Array.from(document.getElementsByClassName(this.#prefix + "-close"));
|
const closeButtons = Array.from(document.getElementsByClassName(this.#prefix + "-close"));
|
||||||
for (const closeButton of closeButtons) {
|
for (const closeButton of closeButtons) {
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
@ -620,7 +627,8 @@ class SummaryHelper {
|
|||||||
}
|
}
|
||||||
this.#reset();
|
this.#reset();
|
||||||
if (!isNew) {
|
if (!isNew) {
|
||||||
this.#populate();
|
summary.value = formSummary.dataset.value;
|
||||||
|
this.#parseAndPopulate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,13 +662,11 @@ class SummaryHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populates the summary helper from the journal entry form.
|
* Parses the summary input and populates the summary helper.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#populate() {
|
#parseAndPopulate() {
|
||||||
const formSummary = document.getElementById("accounting-entry-form-summary");
|
|
||||||
const summary = document.getElementById(this.#prefix + "-summary");
|
const summary = document.getElementById(this.#prefix + "-summary");
|
||||||
summary.value = formSummary.dataset.value;
|
|
||||||
const pos = summary.value.indexOf("—");
|
const pos = summary.value.indexOf("—");
|
||||||
if (pos === -1) {
|
if (pos === -1) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user