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.
face-detect
Noah Petherbridge 2024-01-06 20:44:04 -08:00
parent 9a854e5679
commit 20388172f0
1 changed files with 16 additions and 2 deletions

View File

@ -187,10 +187,24 @@
<script>
window.addEventListener("DOMContentLoaded", (event) => {
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) => {
textarea.value = elem.value;
})
setApproveState();
});
})
});
</script>