From d045f9ecf1a1b29bdffa9bd655394fd90a01ca91 Mon Sep 17 00:00:00 2001 From: phette23 Date: Tue, 8 Oct 2024 15:53:27 -0700 Subject: [PATCH] fix: bug 37496 item barcodes should go to specific item --- admin-js/catalog-detail.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 admin-js/catalog-detail.js diff --git a/admin-js/catalog-detail.js b/admin-js/catalog-detail.js new file mode 100644 index 0000000..80c254d --- /dev/null +++ b/admin-js/catalog-detail.js @@ -0,0 +1,18 @@ +// Bug 37496: Restore parameter to limit to details of one item +if (location.pathname.match('/cgi-bin/koha/catalogue/detail.pl')) { + // holdings table not available on page load + setTimeout(() => { + console.log($('#holdings_table')) + // barcode is literally the only with no unique classname :eyeroll: + $('#holdings_table td > a[href^="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber="]').each(function (idx, el) { + console.log(el) + // parse item id from item#### fragment at end of link + const url = new URL(el.href) + const item = url.hash.match(/#item(\d+)/)[1] + if (item) { + url.searchParams.set('item', item) + $(this).attr('href', url.toString()) + } + }) + }, 1000) +}