Bug 32520

Summary: Patron autocomplete should respect DefaultPatronSearchFields
Product: Koha Reporter: Martin Renvoize <martin.renvoize>
Component: Staff interfaceAssignee: Martin Renvoize <martin.renvoize>
Status: RESOLVED FIXED QA Contact: Katrin Fischer <katrin.fischer>
Severity: minor    
Priority: P5 - low CC: barbara.johnson, gmcharlt
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.03
Bug Depends on:    
Bug Blocks: 32772    
Attachments: Bug 32520: Iterate search_fields
Bug 32520: Use DefaultPatronSearchFields in patron_autocomplete
Bug 32520: Use DefaultPatronSearchFields in patron_autocomplete
Bug 32520: Use DefaultPatronSearchFields in patron_autocomplete
Bug 32520: Amend DefaultPatronSearchFields system preference description

Description Martin Renvoize 2022-12-23 10:13:39 UTC
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.
Comment 1 Martin Renvoize 2022-12-23 11:52:20 UTC
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?
Comment 2 Martin Renvoize 2022-12-28 13:34:23 UTC
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.
Comment 3 ByWater Sandboxes 2022-12-28 17:10:50 UTC
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>
Comment 4 Katrin Fischer 2022-12-28 21:22:11 UTC
I am not sure if the change from 'starts with' to 'contains' will cause any issues, but this works as described now. :)
Comment 5 Katrin Fischer 2022-12-28 21:28:13 UTC
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>
Comment 6 Katrin Fischer 2022-12-28 21:28:17 UTC
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>
Comment 7 Tomás Cohen Arazi 2023-01-27 19:22:59 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 8 Matt Blenkinsop 2023-01-31 14:28:53 UTC
Nice work everyone!

Pushed to stable for 22.11.x