Bug 32520 - Patron autocomplete should respect DefaultPatronSearchFields
Summary: Patron autocomplete should respect DefaultPatronSearchFields
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Martin Renvoize (ashimema)
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on:
Blocks: 32772
  Show dependency treegraph
 
Reported: 2022-12-23 10:13 UTC by Martin Renvoize (ashimema)
Modified: 2024-07-04 20:37 UTC (History)
2 users (show)

See Also:
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
Circulation function:


Attachments
Bug 32520: Iterate search_fields (2.30 KB, patch)
2022-12-23 11:52 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 32520: Use DefaultPatronSearchFields in patron_autocomplete (3.41 KB, patch)
2022-12-28 13:34 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 32520: Use DefaultPatronSearchFields in patron_autocomplete (3.46 KB, patch)
2022-12-28 17:10 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 32520: Use DefaultPatronSearchFields in patron_autocomplete (3.52 KB, patch)
2022-12-28 21:28 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 32520: Amend DefaultPatronSearchFields system preference description (1.58 KB, patch)
2022-12-28 21:28 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 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 (ashimema) 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 (ashimema) 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 (tcohen) 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