Bug 42641: JavaScript errors on patron attribute types admin page

This patch fixes some JavaScript errors on the patron attributes page.
Vanilla JS doesn't automatically handle null variables like jQuery does.

To test, apply the patch and go to Administration -> Patron attribute
types.

- If necessary, add multiple attribute types.
- The table listing all attributes should be displayed as DataTable and
  there should be no errors in the console.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Owen Leonard 2026-05-19 07:24:48 -04:00 committed by Lucas Gass
parent 1640dc10c7
commit 430bfcd76b
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 23 additions and 18 deletions

View File

@ -425,31 +425,36 @@
}
function updateCheckboxes() {
if (!opac_display.checked) {
setDisabled(opac_editable, true);
} else {
setDisabled(opac_editable, false);
if (opac_display && opac_editable) {
if (!opac_display.checked) {
setDisabled(opac_editable, true);
} else {
setDisabled(opac_editable, false);
}
}
if (opac_editable.checked) {
setDisabled(opac_mandatory, false);
} else {
setDisabled(opac_mandatory, true);
if (opac_editable && opac_mandatory) {
if (opac_editable.checked) {
setDisabled(opac_mandatory, false);
} else {
setDisabled(opac_mandatory, true);
}
}
}
opac_display.addEventListener("change", updateCheckboxes);
opac_editable.addEventListener("change", updateCheckboxes);
function toggle_search_default() {
if ($("#staff_searchable").is(":checked")) {
$("#searched_by_default").prop("disabled", false);
} else {
$("#searched_by_default").prop("disabled", true).prop("checked", false);
}
}
opac_display?.addEventListener("change", updateCheckboxes);
opac_editable?.addEventListener("change", updateCheckboxes);
updateCheckboxes();
$(document).ready(function () {
function toggle_search_default() {
if ($("#staff_searchable").is(":checked")) {
$("#searched_by_default").prop("disabled", false);
} else {
$("#searched_by_default").prop("disabled", true).prop("checked", false);
}
}
$("#staff_searchable").on("change", function () {
toggle_search_default();
});
@ -490,7 +495,7 @@
);
});
$("#library_limitation")[0].style.minWidth = "450px";
$("#library_limitation").css("min-width", "450px");
$("#library_limitation").select2();
});
</script>