Bugzilla – Attachment 144862 Details for
Bug 32520
Patron autocomplete should respect DefaultPatronSearchFields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32520: Use DefaultPatronSearchFields in patron_autocomplete
Bug-32520-Use-DefaultPatronSearchFields-in-patrona.patch (text/plain), 3.41 KB, created by
Martin Renvoize (ashimema)
on 2022-12-28 13:34:23 UTC
(
hide
)
Description:
Bug 32520: Use DefaultPatronSearchFields in patron_autocomplete
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-12-28 13:34:23 UTC
Size:
3.41 KB
patch
obsolete
>From 9d7f642f0535972e68fdc9a040e851527250d4d9 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 23 Dec 2022 11:32:12 +0000 >Subject: [PATCH] Bug 32520: Use DefaultPatronSearchFields in > patron_autocomplete > >This patch updates js_includes.inc to set a new global js variable >`defaultPatronSearchFields` with the content of the corresponding system >preference. > >We then update the patron_autocomplete function to use this new global >variable and iterate in the same way as >koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc. > >NOTE: This changes the behaviour of the autocomplete from always >searching using contains on surname or firstname or starts with on >cardnumber to searching using 'contains' on any of the fields listed in >the DefaultPatronSearchFields system preference of defaulting to >'firstname,middle_name,surname,othernames,cardnumber,userid'. > >Test plan >1. Ensure autocomplete still works everywhere >2. Confirm the system preference fields are being used. >--- > .../prog/en/includes/js_includes.inc | 1 + > .../intranet-tmpl/prog/js/patron-autocomplete.js | 15 +++++++-------- > 2 files changed, 8 insertions(+), 8 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >index f040b6ac11c..2d1af01c4f8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >@@ -71,6 +71,7 @@ > [% IF ( PatronAutoComplete ) %] > <script> > // PatronAutoComplete >+ var defaultPatronSearchFields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,middle_name,surname,othernames,cardnumber,userid' | html %]"; > var loggedInLibrary = '[% Branches.GetLoggedInBranchcode | html %]'; > var singleBranchMode = '[% singleBranchMode | html %]'; > var loggedInClass = ""; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js b/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js >index 5f0aeb55592..559b999640d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js >@@ -13,20 +13,19 @@ 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 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 subquery_or = []; >+ defaultPatronSearchFields.split(',').forEach(function(field,i){ >+ subquery_or.push( >+ {["me."+field]: {'like': '%' + pattern + '%'}} >+ ); >+ }); >+ subquery_and.push(subquery_or); > }); > let q = {"-and": subquery_and}; > let params = { >-- >2.39.0
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 32520
:
144816
|
144862
|
144868
|
144878
|
144879