Currently the patron autocomplete functionality is hard coded to search against firstname, surname and cardnumber. We have a customer who understandably expected it to respect the DefaultPatronSearchFields preference and was confused when userid didn't work as a search term. We should really tie the autocomplete search fields to this preference as well.
Created attachment 144816 [details] [review] Bug 32520: Iterate search_fields This pretty much matches the iterators in koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc. Now we need to work out the best way to pass the DefaultPatronSearchFields preference into the search_fields variable.. Perhaps pass it as part of the options at function call time?
Created attachment 144862 [details] [review] 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.
Created attachment 144868 [details] [review] 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. Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov>
I am not sure if the change from 'starts with' to 'contains' will cause any issues, but this works as described now. :)
Created attachment 144878 [details] [review] 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. Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Created attachment 144879 [details] [review] Bug 32520: Amend DefaultPatronSearchFields system preference description Tries to clarify that the preference is not only used for the search in the patrons module, but also in circulation. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Pushed to master for 23.05. Nice work everyone, thanks!
Nice work everyone! Pushed to stable for 22.11.x