Prepend all the HTML ID and class names with "accounting-" to avoid name conflict.
This commit is contained in:
@ -24,11 +24,11 @@
|
||||
// Initializes the page JavaScript.
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
initializeBaseAccountSelector();
|
||||
document.getElementById("account-base-code")
|
||||
document.getElementById("accounting-base-code")
|
||||
.onchange = validateBase;
|
||||
document.getElementById("account-title")
|
||||
document.getElementById("accounting-title")
|
||||
.onchange = validateTitle;
|
||||
document.getElementById("account-form")
|
||||
document.getElementById("accounting-form")
|
||||
.onsubmit = validateForm;
|
||||
});
|
||||
|
||||
@ -38,25 +38,25 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
* @private
|
||||
*/
|
||||
function initializeBaseAccountSelector() {
|
||||
const selector = document.getElementById("select-base-modal");
|
||||
const base = document.getElementById("account-base");
|
||||
const baseCode = document.getElementById("account-base-code");
|
||||
const baseContent = document.getElementById("account-base-content");
|
||||
const options = Array.from(document.getElementsByClassName("list-group-item-base"));
|
||||
const btnClear = document.getElementById("btn-clear-base");
|
||||
const selector = document.getElementById("accounting-base-selector-model");
|
||||
const base = document.getElementById("accounting-base");
|
||||
const baseCode = document.getElementById("accounting-base-code");
|
||||
const baseContent = document.getElementById("accounting-base-content");
|
||||
const options = Array.from(document.getElementsByClassName("accounting-base-option"));
|
||||
const btnClear = document.getElementById("accounting-btn-clear-base");
|
||||
selector.addEventListener("show.bs.modal", function () {
|
||||
base.classList.add("not-empty");
|
||||
base.classList.add("accounting-not-empty");
|
||||
options.forEach(function (item) {
|
||||
item.classList.remove("active");
|
||||
});
|
||||
const selected = document.getElementById("list-group-item-base-" + baseCode.value);
|
||||
const selected = document.getElementById("accounting-base-option-" + baseCode.value);
|
||||
if (selected !== null) {
|
||||
selected.classList.add("active");
|
||||
}
|
||||
});
|
||||
selector.addEventListener("hidden.bs.modal", function () {
|
||||
if (baseCode.value === "") {
|
||||
base.classList.remove("not-empty");
|
||||
base.classList.remove("accounting-not-empty");
|
||||
}
|
||||
});
|
||||
options.forEach(function (option) {
|
||||
@ -101,9 +101,9 @@ function validateForm() {
|
||||
* @private
|
||||
*/
|
||||
function validateBase() {
|
||||
const field = document.getElementById("account-base-code");
|
||||
const error = document.getElementById("account-base-code-error");
|
||||
const displayField = document.getElementById("account-base");
|
||||
const field = document.getElementById("accounting-base-code");
|
||||
const error = document.getElementById("accounting-base-code-error");
|
||||
const displayField = document.getElementById("accounting-base");
|
||||
field.value = field.value.trim();
|
||||
if (field.value === "") {
|
||||
displayField.classList.add("is-invalid");
|
||||
@ -122,8 +122,8 @@ function validateBase() {
|
||||
* @private
|
||||
*/
|
||||
function validateTitle() {
|
||||
const field = document.getElementById("account-title");
|
||||
const error = document.getElementById("account-title-error");
|
||||
const field = document.getElementById("accounting-title");
|
||||
const error = document.getElementById("accounting-title-error");
|
||||
field.value = field.value.trim();
|
||||
if (field.value === "") {
|
||||
field.classList.add("is-invalid");
|
||||
|
@ -23,13 +23,13 @@
|
||||
|
||||
// Initializes the page JavaScript.
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const list = document.getElementById("account-order-list");
|
||||
const list = document.getElementById("accounting-order-list");
|
||||
if (list !== null) {
|
||||
const onReorder = function () {
|
||||
const accounts = Array.from(list.children);
|
||||
for (let i = 0; i < accounts.length; i++) {
|
||||
const no = document.getElementById("account-order-" + accounts[i].dataset.id + "-no");
|
||||
const code = document.getElementById("account-order-" + accounts[i].dataset.id + "-code");
|
||||
const no = document.getElementById("accounting-order-" + accounts[i].dataset.id + "-no");
|
||||
const code = document.getElementById("accounting-order-" + accounts[i].dataset.id + "-code");
|
||||
no.value = String(i + 1);
|
||||
code.innerText = list.dataset.baseCode + "-" + ("000" + (i + 1)).slice(-3);
|
||||
}
|
||||
|
@ -23,11 +23,11 @@
|
||||
|
||||
// Initializes the page JavaScript.
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
document.getElementById("currency-code")
|
||||
document.getElementById("accounting-code")
|
||||
.onchange = validateCode;
|
||||
document.getElementById("currency-name")
|
||||
document.getElementById("accounting-name")
|
||||
.onchange = validateName;
|
||||
document.getElementById("currency-form")
|
||||
document.getElementById("accounting-form")
|
||||
.onsubmit = validateForm;
|
||||
});
|
||||
|
||||
@ -69,7 +69,7 @@ function submitFormIfAllAsyncValid() {
|
||||
isValid = isAsyncValid[key] && isValid;
|
||||
});
|
||||
if (isValid) {
|
||||
document.getElementById("currency-form").submit()
|
||||
document.getElementById("accounting-form").submit()
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,8 +84,8 @@ function validateCode(changeEvent = null) {
|
||||
const key = "code";
|
||||
const isSubmission = changeEvent === null;
|
||||
let hasAsyncValidation = false;
|
||||
const field = document.getElementById("currency-code");
|
||||
const error = document.getElementById("currency-code-error");
|
||||
const field = document.getElementById("accounting-code");
|
||||
const error = document.getElementById("accounting-code-error");
|
||||
field.value = field.value.trim();
|
||||
if (field.value === "") {
|
||||
field.classList.add("is-invalid");
|
||||
@ -125,8 +125,8 @@ function validateCode(changeEvent = null) {
|
||||
* @private
|
||||
*/
|
||||
function validateAsyncCodeIsDuplicated(isSubmission, key) {
|
||||
const field = document.getElementById("currency-code");
|
||||
const error = document.getElementById("currency-code-error");
|
||||
const field = document.getElementById("accounting-code");
|
||||
const error = document.getElementById("accounting-code-error");
|
||||
const url = field.dataset.existsUrl;
|
||||
const onLoad = function () {
|
||||
if (this.status === 200) {
|
||||
@ -160,8 +160,8 @@ function validateAsyncCodeIsDuplicated(isSubmission, key) {
|
||||
* @private
|
||||
*/
|
||||
function validateName() {
|
||||
const field = document.getElementById("currency-name");
|
||||
const error = document.getElementById("currency-name-error");
|
||||
const field = document.getElementById("accounting-name");
|
||||
const error = document.getElementById("accounting-name-error");
|
||||
field.value = field.value.trim();
|
||||
if (field.value === "") {
|
||||
field.classList.add("is-invalid");
|
||||
|
Reference in New Issue
Block a user