From bd4f59cd9aef0b271450d97bd87ae29c60730bcd Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 27 Jun 2023 09:08:52 +0000 Subject: [PATCH] Bug 34058: Use buildSearchPatronQuery when searching for patrons on left side filters This will now use the centered logic from buildSearchPatronQuery, not only fixing the original issue of not being considering all the terms in the search input, but also reusing already established code. Test plan, k-t-d: 1) Install FreeForm, enable ILLModule sys pref, run: bash <(curl -s https://raw.githubusercontent.com/ammopt/koha-ill-dev/master/start-ill-dev.sh) 2) Create a FreeForm ILL request and input 23529000035676 in the cardnumber, that's "Henry Acevedo". 3) Go back to the ILL list table, input "henry" in the bottom "Patron" filter input and press the "Search" button, notice it fetches the request correctly. 4) Now do the the same search but with "henry acevedo", notice the request is not retrieved. 5) Apply patch. Repeat. Do the same for the "patron" input field and the "keyword" input field. Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- .../intranet-tmpl/prog/js/ill-list-table.js | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js index ef090e8102..8d564a4ee7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js @@ -86,26 +86,19 @@ $(document).ready(function() { let patron = $("#illfilter_patron").val(); let status = $("#illfilter_status").val(); let filters = []; - let patron_sub_or = []; let status_sub_or = []; let subquery_and = []; if (!patron && !status) return ""; if(patron){ - const patron_search_fields = "me.borrowernumber,patron.cardnumber,patron.firstname,patron.surname"; - patron_search_fields.split(',').forEach(function(attr){ - let operator = "="; - let patron_data = patron; - if ( attr != "me.borrowernumber" && attr != "patron.cardnumber") { - operator = "like"; - patron_data = "%" + patron + "%"; + let patronquery = buildPatronSearchQuery( + patron, + { + table_prefix: 'patron', } - patron_sub_or.push({ - [attr]:{[operator]: patron_data } - }); - }); - subquery_and.push(patron_sub_or); + ); + subquery_and.push(patronquery); } if(status){ @@ -154,7 +147,7 @@ $(document).ready(function() { let filters = []; let subquery_and = []; - const search_fields = "me.illrequest_id,me.borrowernumber,me.biblio_id,me.due_date,me.branchcode,library.name,me.status,me.status_alias,me.placed,me.replied,me.updated,me.completed,me.medium,me.accessurl,me.cost,me.price_paid,me.notesopac,me.notesstaff,me.orderid,me.backend,patron.firstname,patron.surname"; + const search_fields = "me.illrequest_id,me.biblio_id,me.due_date,me.branchcode,library.name,me.status,me.status_alias,me.placed,me.replied,me.updated,me.completed,me.medium,me.accessurl,me.cost,me.price_paid,me.notesopac,me.notesstaff,me.orderid,me.backend"; let sub_or = []; search_fields.split(',').forEach(function(attr){ sub_or.push({ @@ -164,6 +157,14 @@ $(document).ready(function() { subquery_and.push(sub_or); filters.push({"-and": subquery_and}); + let patronquery = buildPatronSearchQuery( + keyword, + { + table_prefix: 'patron', + } + ); + filters.push(patronquery); + const extended_attributes = "title,type,author,article_title,pages,issue,volume,year"; let extended_sub_or = []; subquery_and = []; -- 2.39.5