From 430bfcd76b527570dd1fd82819414af72a1dff7a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 19 May 2026 07:24:48 -0400 Subject: [PATCH] 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 Signed-off-by: Lucas Gass --- .../en/modules/admin/patron-attr-types.tt | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt index cb4c9cf6fb..d409cc6a69 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt @@ -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(); });