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 <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Owen Leonard 2022-05-05 14:21:19 +00:00 committed by Martin Renvoize
parent 63d324db28
commit f6a0eb3a2a
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 12 additions and 9 deletions

View File

@ -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();
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();
});
}
/* 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') ) {