From ea4cb8ff854a746d3f6869d36e8048d12e2e53c1 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 19 Oct 2023 16:59:20 +0100 Subject: [PATCH] Bug 29002: Use buildPatronSearchQuery in patron select Rebased to use the standardised patron search query builder that has been introduced more recently. Signed-off-by: Martin Renvoize Signed-off-by: Janet McGowan Signed-off-by: Caroline Cyr La Rose Signed-off-by: Laurence Rault Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- .../prog/js/place_booking_modal.js | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js b/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js index f457aa2179..a021635d95 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js @@ -39,28 +39,11 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { "x-koha-embed": "library" }, data: function(params) { - let search_term = (params.term === undefined) ? '' : params.term; + let q = buildPatronSearchQuery(params.term); let query = { - 'q': JSON.stringify({ - "-or": [{ - "firstname": { - "-like": search_term + '%' - } - }, - { - "surname": { - "-like": search_term + '%' - } - }, - { - "cardnumber": { - "-like": search_term + '%' - } - } - ] - }), - '_order_by': '+me.surname,+me.firstname', + 'q': JSON.stringify(q), '_page': params.page, + '_order_by': '+me.surname,+me.firstname', }; return query; }, @@ -92,15 +75,22 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { ? escape_str(patron.firstname) + " " : "") + (patron.cardnumber - ? " (" + escape_str(patron.cardnumber) + ") " + ? " (" + escape_str(patron.cardnumber) + ")" : "") + + "" + (patron.date_of_birth - ? '' + + ? ' ' + $get_age(patron.date_of_birth) + " " + __("years") + - "" - : "") + "" + : "") + + (patron.library ? + " " + + escape_str(patron.library.name) + + "" + : "") + + "" ) .addClass(loggedInClass); return $patron; -- 2.39.5