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>
(cherry picked from commit 430bfcd76b)
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
This commit is contained in:
Owen Leonard 2026-05-19 07:24:48 -04:00 committed by Baptiste Wojtkowski
parent c1c3e8c605
commit e77759a166
No known key found for this signature in database
GPG Key ID: 47A8A13E10BC0D40
1 changed files with 12 additions and 7 deletions

View File

@ -425,24 +425,22 @@
}
function updateCheckboxes() {
if (opac_display && opac_editable) {
if (!opac_display.checked) {
setDisabled(opac_editable, true);
} else {
setDisabled(opac_editable, false);
}
}
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);
updateCheckboxes();
$(document).ready(function () {
function toggle_search_default() {
if ($("#staff_searchable").is(":checked")) {
$("#searched_by_default").prop("disabled", false);
@ -450,6 +448,13 @@
$("#searched_by_default").prop("disabled", true).prop("checked", false);
}
}
opac_display?.addEventListener("change", updateCheckboxes);
opac_editable?.addEventListener("change", updateCheckboxes);
updateCheckboxes();
$(document).ready(function () {
$("#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>