Bugzilla – Attachment 152883 Details for
Bug 34092
patron-autocomplete.js and patron-search.inc search logic should match
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34092: Preparation: New buildPatronSearchQuery function
Bug-34092-Preparation-New-buildPatronSearchQuery-f.patch (text/plain), 3.76 KB, created by
Marcel de Rooy
on 2023-06-30 07:13:57 UTC
(
hide
)
Description:
Bug 34092: Preparation: New buildPatronSearchQuery function
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-06-30 07:13:57 UTC
Size:
3.76 KB
patch
obsolete
>From 1155d5a4137ccaaa850555bced8ee737dc2ad5b7 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Mon, 26 Jun 2023 12:37:08 +0000 >Subject: [PATCH] Bug 34092: Preparation: New buildPatronSearchQuery function >Content-Type: text/plain; charset=utf-8 > >Move patron search query logic out of patron_autocomplete into new function > >Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > .../intranet-tmpl/prog/js/staff-global.js | 62 +++++++++++-------- > 1 file changed, 36 insertions(+), 26 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 04219caa40..80d594c458 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -403,7 +403,7 @@ function patron_autocomplete(node, options) { > let link_to; > let url_params; > let on_select_callback; >- let leading_wildcard = defaultPatronSearchMethod === 'contains' ? '%' : ''; >+ > if (options) { > if (options['link-to']) { > link_to = options['link-to']; >@@ -417,31 +417,7 @@ function patron_autocomplete(node, options) { > } > return node.autocomplete({ > source: function (request, response) { >- let q = [] >- >- // Add each pattern in search term for each search field >- let pattern_subquery_and = []; >- request.term.split(/[\s,]+/) >- .filter(function (s) { return s.length }) >- .forEach(function (pattern, i) { >- let pattern_subquery_or = []; >- defaultPatronSearchFields.split(',').forEach(function (field, i) { >- pattern_subquery_or.push( >- { ["me." + field]: { 'like': leading_wildcard + pattern + '%' } } >- ); >- }); >- pattern_subquery_and.push(pattern_subquery_or); >- }); >- q.push({ "-and": pattern_subquery_and }); >- >- // Add full search term for each search field >- let term_subquery_or = []; >- defaultPatronSearchFields.split(',').forEach(function (field, i) { >- term_subquery_or.push( >- { ["me." + field]: { 'like': leading_wildcard + request.term + '%' } } >- ); >- }); >- q.push({ "-or": term_subquery_or }); >+ let q = buildPatronSearchQuery(request.term); > > let params = { > '_page': 1, >@@ -533,3 +509,37 @@ function patron_autocomplete(node, options) { > .appendTo(ul); > }; > } >+ >+ >+function buildPatronSearchQuery(term) { >+ >+ let q = []; >+ let leading_wildcard = defaultPatronSearchMethod === 'contains' ? '%' : ''; >+ >+ // Add each pattern for each search field >+ let pattern_subquery_and = []; >+ term.split(/[\s,]+/) >+ .filter(function (s) { return s.length }) >+ .forEach(function (pattern, i) { >+ let pattern_subquery_or = []; >+ defaultPatronSearchFields.split(',').forEach(function (field, i) { >+ pattern_subquery_or.push( >+ { ["me." + field]: { 'like': leading_wildcard + pattern + '%' } } >+ ); >+ }); >+ pattern_subquery_and.push(pattern_subquery_or); >+ }); >+ q.push({ "-and": pattern_subquery_and }); >+ >+ // Add full search term for each search field >+ let term_subquery_or = []; >+ defaultPatronSearchFields.split(',').forEach(function (field, i) { >+ term_subquery_or.push( >+ { ["me." + field]: { 'like': leading_wildcard + term + '%' } } >+ ); >+ }); >+ q.push({ "-or": term_subquery_or }); >+ >+ >+ return q; >+} >-- >2.30.2
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 34092
:
152682
|
152683
|
152684
|
152698
|
152830
|
152831
|
152832
|
152854
|
152855
|
152856
|
152882
| 152883 |
152884
|
152885
|
152891