From cf5dc671ff1e3c24044d4b4b3930f03b584ca730 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 13 Aug 2025 22:11:07 +0000 Subject: [PATCH] Bug 31698: Make searches return only exact matches for barcode/biblionumber --- .../prog/en/modules/reserve/request.tt | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 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 68c6017d6f0..e89e49a0857 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1843,9 +1843,11 @@ method: "GET", dataType: "json", success: function (data) { - if (data.length > 0) { + // Filter for exact matches only + let exactMatches = data.filter(item => item.external_id === externalID); + if (exactMatches.length > 0) { let resultHtml = ""; - $.each(data, function (index, item) { + $.each(exactMatches, function (index, item) { resultHtml += `
Biblionumber: ${item.biblio_id}
@@ -1871,7 +1873,7 @@ event.preventDefault(); $('#move_hold_biblio_confirm').prop('disabled' , true ); - let biblioID = $("#biblio_id").val(); + let biblioID = parseInt( $("#biblio_id").val() ); let apiUrl = `/api/v1/biblios?q={"biblio_id":"${encodeURIComponent(biblioID)}"}`; $.ajax({ url: apiUrl, @@ -1881,9 +1883,13 @@ 'Accept': 'application/json' }, success: function (data) { - if (data.length > 0) { + // Filter for exact matches only + let exactMatches = data.filter(item => item.biblio_id === biblioID); + + + if (exactMatches.length > 0) { let resultHtml = ""; - $.each(data, function (index, item) { + $.each(exactMatches, function (index, item) { resultHtml += `
Biblionumber: ${item.biblio_id}
@@ -1896,10 +1902,10 @@ $("#biblioResultMessage").html(resultHtml); } else { $("#biblioResultMessage").html(` -
No item found with barcode: ${biblioID}.
+
No record found with biblionumber: ${biblioID}.
`); } - }, + } }); }); @@ -2033,7 +2039,7 @@ $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length)); $('#cancel_hold_alert').show(); localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')); - $('#item_record_choice').prop('disabled' , count ); + $('#item_record_choice').prop('disabled' , !$('.select_hold:checked').length ); }); $('.holds_table .select_hold').click(function() { @@ -2044,7 +2050,7 @@ $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length)); $('#cancel_hold_alert').show(); localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')); - $('#item_record_choice').prop('disabled' , count ); + $('#item_record_choice').prop('disabled' , !$('.select_hold:checked').length ); }); $('.move_hold_item').click(function(e) { -- 2.39.5