Bug 32176

Summary: Correctly display patrons when selected after autocomplete (was js/patron-autocomplete.js need another option)
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrew
Version: unspecified   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 40958    
Bug Blocks: 40995    
Attachments: Bug 32176: Remove duplicated code to select patron from autocomplete
Bug 32176: Use patron_to_html
Bug 32176: Fix list transfer
Bug 32176: Remove duplicated code to select patron from autocomplete
Bug 32176: Use patron_to_html
Bug 32176: Fix list transfer
Bug 32176: Fix punctuation in patron search
Bug 32176: Add Cypress tests

Description Jonathan Druart 2022-11-11 11:32:06 UTC
See commit message from "Bug 31782: Remove js/autocomplete/patrons.js"

We need another option in this function, and remove code duplicate from patron_lists/list.tt, acqui/histsearch.tt and acqui/duplicate_orders.tt
Comment 1 Jonathan Druart 2025-10-06 14:17:54 UTC
Created attachment 187477 [details] [review]
Bug 32176: Remove duplicated code to select patron from autocomplete

On bug 31782 we centralized the code to autocomplete when searching for patron
There were several occurrences in the code where some code were
duplicated (when selecting patrons and allowing to remove them from a
list).

This patch centralizes this code by adding another parameter to
patron_autocomplete: on-select-add-to

Test plan:
When duplicating an order, searching for orders, editing a course (and
adding instructors) and adding patrons to a patron list, you should now
see the correct patron details displayed: with preferred name, without
"null" in case of missing surname, correct spacing, etc. Like (almost)
everywhere else in Koha.
Comment 2 Jonathan Druart 2025-10-06 14:17:56 UTC
Created attachment 187478 [details] [review]
Bug 32176: Use patron_to_html

Thanks to bug 40958.
Comment 3 Jonathan Druart 2025-10-06 14:17:59 UTC
Created attachment 187479 [details] [review]
Bug 32176: Fix list transfer
Comment 4 Andrew Fuerste-Henry 2025-10-07 15:35:01 UTC
I get the following error when attempting to create a course with these patches applied: 
Template process failed: file error - js-patron-format.inc: not found at /kohadevbox/koha/C4/Templates.pm line 146
Comment 5 Jonathan Druart 2025-10-07 17:02:12 UTC
(In reply to Andrew Fuerste-Henry from comment #4)
> I get the following error when attempting to create a course with these
> patches applied: 
> Template process failed: file error - js-patron-format.inc: not found at
> /kohadevbox/koha/C4/Templates.pm line 146

Do you have bug 40958 applied?
Comment 6 Andrew Fuerste-Henry 2025-10-07 17:14:49 UTC
(In reply to Jonathan Druart from comment #5)

> Do you have bug 40958 applied?

Yes
Comment 7 Jonathan Druart 2025-10-09 09:09:26 UTC
(In reply to Andrew Fuerste-Henry from comment #6)
> (In reply to Jonathan Druart from comment #5)
> 
> > Do you have bug 40958 applied?
> 
> Yes

Indeed, sorry! There was a problem in the dependency tree. I have added a patch to bug 40958 to remove the occurrence added by bug 40699.
Comment 8 Andrew Fuerste-Henry 2025-10-10 12:42:33 UTC
Created attachment 187728 [details] [review]
Bug 32176: Remove duplicated code to select patron from autocomplete

On bug 31782 we centralized the code to autocomplete when searching for patron
There were several occurrences in the code where some code were
duplicated (when selecting patrons and allowing to remove them from a
list).

This patch centralizes this code by adding another parameter to
patron_autocomplete: on-select-add-to

Test plan:
When duplicating an order, searching for orders, editing a course (and
adding instructors) and adding patrons to a patron list, you should now
see the correct patron details displayed: with preferred name, without
"null" in case of missing surname, correct spacing, etc. Like (almost)
everywhere else in Koha.

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 9 Andrew Fuerste-Henry 2025-10-10 12:42:35 UTC
Created attachment 187729 [details] [review]
Bug 32176: Use patron_to_html

Thanks to bug 40958.

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 10 Andrew Fuerste-Henry 2025-10-10 12:42:38 UTC
Created attachment 187730 [details] [review]
Bug 32176: Fix list transfer

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 11 Andrew Fuerste-Henry 2025-10-10 12:48:35 UTC
(In reply to Andrew Fuerste-Henry from comment #8)
> without "null" in case of missing surname, correct spacing, etc. Like (almost)
> everywhere else in Koha.

Oop, signed off too soon. When I removed Henry's surname I get ", Henry" in autocompletes.
Comment 12 Andrew Fuerste-Henry 2025-10-10 14:04:13 UTC
Back to signed off. The issue I ran into with ", Henry" is existing problematic behavior for which I'll file a new bug.
Comment 13 Jonathan Druart 2025-10-13 13:58:43 UTC
Created attachment 187841 [details] [review]
Bug 32176: Fix punctuation in patron search
Comment 14 Jonathan Druart 2025-10-13 13:59:05 UTC
Created attachment 187842 [details] [review]
Bug 32176: Add Cypress tests
Comment 15 Jonathan Druart 2025-10-13 14:02:05 UTC
(In reply to Andrew Fuerste-Henry from comment #12)
> Back to signed off. The issue I ran into with ", Henry" is existing
> problematic behavior for which I'll file a new bug.

The last 2 patches fix the punctuation problem on the patron searches. On bug 40995 we will deal with the autocomplete.

And we now have Cypress tests \o/