From f6a0eb3a2a201c9ddb07b626653563faebe4434d Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 5 May 2022 14:21:19 +0000 Subject: [PATCH] Bug 30693: Javascript broken on request.pl The holds page in the staff interface has some JavaScript relating to Bootstrap tabs, but the tabs are not always present on the page. This leads to a JS error after you have selected the patron for the hold. This patch adds a check for the tabs container element before executing the code. To test, apply the patch and locate a bibliographic record on which to place a hold. - On the initial holds screen should see tabs for "Patrons" and "Clubs." Both should work correctly. - Select a patron to place the hold for. - On the page where you enter hold details (pickup library, hold expiration, etc.) there should be no JavaScript error in the console. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize --- .../prog/en/modules/reserve/request.tt | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 5319d2fec4..65d95f6e0f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1194,16 +1194,19 @@ } }); - [% SET active = clubs ? 1 : 0 %] - /* Set active tab based on whether a club search was submitted */ - var tabs = $("#circ_holds_select li:eq(" + [% active | $raw %] + ") a").tab("show"); - $( tabs[0].hash ).find("input.focus").focus(); - - /* Change active focus when tabs change */ - $("#circ_holds_select a[data-toggle='tab']").on("shown.bs.tab", function (e) { - active_tab = e.target.hash; - $( active_tab ).find("input.focus").focus(); - }); + if( $("#circ_holds_select").length > 0 ){ + [% SET active = clubs ? 1 : 0 %] + /* Set active tab based on whether a club search was submitted */ + var tabs = $("#circ_holds_select li:eq(" + [% active | $raw %] + ") a").tab("show"); + $( tabs[0].hash ).find("input.focus").focus(); + + /* Change active focus when tabs change */ + $("#circ_holds_select a[data-toggle='tab']").on("shown.bs.tab", function (e) { + active_tab = e.target.hash; + $( active_tab ).find("input.focus").focus(); + }); + } + function ToggleHoldsToPlace() { if ( $("#requestany").prop('checked') ) { -- 2.39.5