Safety on admin certification photos page

If a rejection reason is filled out, the approve button will disable so
you don't accidentally click it.
This commit is contained in:
Noah Petherbridge 2024-01-06 20:44:04 -08:00
parent 9a854e5679
commit 20388172f0

View File

@ -187,10 +187,24 @@
<script> <script>
window.addEventListener("DOMContentLoaded", (event) => { window.addEventListener("DOMContentLoaded", (event) => {
document.querySelectorAll("select.common-reasons").forEach(elem => { document.querySelectorAll("select.common-reasons").forEach(elem => {
let textarea = elem.parentNode.parentNode.getElementsByTagName("textarea")[0]; let textarea = elem.parentNode.parentNode.getElementsByTagName("textarea")[0],
approveButton = elem.parentNode.parentNode.parentNode.parentNode.querySelector("button.is-success");
// Grey out the Approve button if a rejection reason is filled out.
let setApproveState = () => {
if (textarea.value.length > 0) {
approveButton.disabled = "disabled";
} else {
approveButton.disabled = null;
}
};
textarea.addEventListener("change", setApproveState);
textarea.addEventListener("keyup", setApproveState);
elem.addEventListener("change", (e) => { elem.addEventListener("change", (e) => {
textarea.value = elem.value; textarea.value = elem.value;
}) setApproveState();
});
}) })
}); });
</script> </script>