From e77759a166d6018c07508b2a6c5cf14b7e121477 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 (cherry picked from commit 430bfcd76b527570dd1fd82819414af72a1dff7a) Signed-off-by: Baptiste Wojtkowski --- .../en/modules/admin/patron-attr-types.tt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 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 631a41867b..3a19bbab2b 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,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(); });