Bugzilla – Attachment 136134 Details for
Bug 30578
We should drop circ/ysearch.pl in preference to using the REST API's
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30578: Fix multi-terms search
Bug-30578-Fix-multi-terms-search.patch (text/plain), 3.39 KB, created by
Martin Renvoize (ashimema)
on 2022-06-16 08:51:17 UTC
(
hide
)
Description:
Bug 30578: Fix multi-terms search
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-06-16 08:51:17 UTC
Size:
3.39 KB
patch
obsolete
>From 8a038b5eb85e8cbe2fd87d687537b572d7ef1dc8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 13 Jun 2022 20:58:44 +0200 >Subject: [PATCH] Bug 30578: Fix multi-terms search > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../prog/js/patron-autocomplete.js | 58 +++++++++++-------- > 1 file changed, 34 insertions(+), 24 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js b/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js >index 154b96aa70..6057cb8473 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js >@@ -13,33 +13,43 @@ function patron_autocomplete(node, options) { > on_select_callback = options['on-select-callback']; > } > } >+ const search_fields = ['me.surname', 'me.firstname', 'me.cardnumber']; > return node.autocomplete({ > source: function( request, response ) { >- let params = { >- '_page': 1, >- '_per_page': 10, >- 'q': JSON.stringify([ >- {"me.firstname": {"like": "%"+request.term+"%"}}, >- {"me.surname": {"like": "%"+request.term+"%"}}, >- {"me.cardnumber": {"like": request.term+"%"}} >- ]), >- '_order_by': '+me.surname,+me.firstname', >- }; >- $.ajax({ >- data: params, >- type: 'GET', >- url: '/api/v1/patrons', >- headers: { >- "x-koha-embed": "library" >- }, >- success: function(data) { >- return response(data); >- }, >- error: function() { >- alert( _("An error occurred. Check the logs") ); >- return response(); >- } >+ let subquery_and = []; >+ request.term.split(' ') >+ .filter(function(s){ return s.length }) >+ .forEach(function(pattern,i){ >+ subquery_and.push( >+ [ >+ {'me.surname': {'like': '%' + pattern + '%'}}, >+ {'me.firstname': {'like': '%' + pattern + '%'}}, >+ {'me.cardnumber': {'like': pattern + '%'}}, >+ ] >+ ); > }); >+ let q = {"-and": subquery_and}; >+ let params = { >+ '_page': 1, >+ '_per_page': 10, >+ 'q': JSON.stringify(q), >+ '_order_by': '+me.surname,+me.firstname', >+ }; >+ $.ajax({ >+ data: params, >+ type: 'GET', >+ url: '/api/v1/patrons', >+ headers: { >+ "x-koha-embed": "library" >+ }, >+ success: function(data) { >+ return response(data); >+ }, >+ error: function() { >+ alert( _("An error occurred. Check the logs") ); >+ return response(); >+ } >+ }); > }, > minLength: 3, > select: function( event, ui ) { >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30578
:
135856
|
135920
|
136041
|
136042
|
136043
|
136044
|
136085
|
136086
|
136087
|
136088
|
136089
|
136130
|
136131
|
136132
|
136133
|
136134
|
136575
|
136576
|
136577
|
136578
|
136579