25 lines
977 B
JavaScript
25 lines
977 B
JavaScript
(() => {
|
|
"use strict";
|
|
const form = document.getElementById("branchdetail");
|
|
const bank = document.getElementById("bank");
|
|
document.getElementById("branchname")?.focus();
|
|
|
|
document.getElementById("cancelBranch")?.addEventListener("click", () => {
|
|
window.parent.postMessage({ type: "matrix:modal-close" }, window.location.origin);
|
|
});
|
|
|
|
form?.addEventListener("submit", (event) => {
|
|
bank.setCustomValidity(bank.value === "-1" ? "Select a bank" : "");
|
|
if (!form.checkValidity()) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
}
|
|
form.classList.add("was-validated");
|
|
});
|
|
bank?.addEventListener("change", () => bank.setCustomValidity(bank.value === "-1" ? "Select a bank" : ""));
|
|
|
|
if (document.body.dataset.saveComplete === "true") {
|
|
window.parent.postMessage({ type: "matrix:branch-saved", value: document.body.dataset.result }, window.location.origin);
|
|
}
|
|
})();
|