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 <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
c162b8aa46
commit
bd4f59cd9a
|
|
@ -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 = [];
|
||||
|
|
|
|||
Loading…
Reference in New Issue