Replaced the forEach loops with the for-of loops in the JavaScript for the currency form, account form, and the drag-and-drop reorder library functions.
This commit is contained in:
parent
bb7e9e94ee
commit
08dc24605d
@ -46,9 +46,9 @@ function initializeBaseAccountSelector() {
|
||||
const btnClear = document.getElementById("accounting-btn-clear-base");
|
||||
selector.addEventListener("show.bs.modal", function () {
|
||||
base.classList.add("accounting-not-empty");
|
||||
options.forEach(function (item) {
|
||||
item.classList.remove("active");
|
||||
});
|
||||
for (const option of options) {
|
||||
option.classList.remove("active");
|
||||
}
|
||||
const selected = document.getElementById("accounting-base-option-" + baseCode.value);
|
||||
if (selected !== null) {
|
||||
selected.classList.add("active");
|
||||
@ -59,7 +59,7 @@ function initializeBaseAccountSelector() {
|
||||
base.classList.remove("accounting-not-empty");
|
||||
}
|
||||
});
|
||||
options.forEach(function (option) {
|
||||
for (const option of options) {
|
||||
option.onclick = function () {
|
||||
baseCode.value = option.dataset.code;
|
||||
baseContent.innerText = option.dataset.content;
|
||||
@ -69,7 +69,7 @@ function initializeBaseAccountSelector() {
|
||||
validateBase();
|
||||
bootstrap.Modal.getInstance(selector).hide();
|
||||
};
|
||||
});
|
||||
}
|
||||
btnClear.onclick = function () {
|
||||
baseCode.value = "";
|
||||
baseContent.innerText = "";
|
||||
@ -94,15 +94,15 @@ function initializeBaseAccountQuery() {
|
||||
const queryNoResult = document.getElementById("accounting-base-option-no-result");
|
||||
query.addEventListener("input", function () {
|
||||
if (query.value === "") {
|
||||
options.forEach(function (option) {
|
||||
for (const option of options) {
|
||||
option.classList.remove("d-none");
|
||||
});
|
||||
}
|
||||
optionList.classList.remove("d-none");
|
||||
queryNoResult.classList.add("d-none");
|
||||
return
|
||||
}
|
||||
let hasAnyMatched = false;
|
||||
options.forEach(function (option) {
|
||||
for (const option of options) {
|
||||
const queryValues = JSON.parse(option.dataset.queryValues);
|
||||
let isMatched = false;
|
||||
for (const queryValue of queryValues) {
|
||||
@ -117,7 +117,7 @@ function initializeBaseAccountQuery() {
|
||||
} else {
|
||||
option.classList.add("d-none");
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!hasAnyMatched) {
|
||||
optionList.classList.add("d-none");
|
||||
queryNoResult.classList.remove("d-none");
|
||||
|
@ -65,9 +65,9 @@ function validateForm() {
|
||||
*/
|
||||
function submitFormIfAllAsyncValid() {
|
||||
let isValid = true;
|
||||
Object.keys(isAsyncValid).forEach(function (key) {
|
||||
for (const key of Object.keys(isAsyncValid)) {
|
||||
isValid = isAsyncValid[key] && isValid;
|
||||
});
|
||||
}
|
||||
if (isValid) {
|
||||
document.getElementById("accounting-form").submit()
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ function initializeDragAndDropReordering(list, onReorder) {
|
||||
function initializeMouseDragAndDropReordering(list, onReorder) {
|
||||
const items = Array.from(list.children);
|
||||
let dragged = null;
|
||||
items.forEach(function (item) {
|
||||
for (const item of items) {
|
||||
item.draggable = true;
|
||||
item.addEventListener("dragstart", function () {
|
||||
dragged = item;
|
||||
@ -56,7 +56,7 @@ function initializeMouseDragAndDropReordering(list, onReorder) {
|
||||
dragged.classList.remove("accounting-dragged");
|
||||
dragged = null;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,7 +68,7 @@ function initializeMouseDragAndDropReordering(list, onReorder) {
|
||||
*/
|
||||
function initializeTouchDragAndDropReordering(list, onReorder) {
|
||||
const items = Array.from(list.children);
|
||||
items.forEach(function (item) {
|
||||
for (const item of items) {
|
||||
item.addEventListener("touchstart", function () {
|
||||
item.classList.add("accounting-dragged");
|
||||
});
|
||||
@ -81,7 +81,7 @@ function initializeTouchDragAndDropReordering(list, onReorder) {
|
||||
item.addEventListener("touchend", function () {
|
||||
item.classList.remove("accounting-dragged");
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user