Bug 31782 - Patron autocomplete broken when using js/autocomplete/patrons.js
Summary: Patron autocomplete broken when using js/autocomplete/patrons.js
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P5 - low critical
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords: rel_22_11_candidate
: 32015 (view as bug list)
Depends on: 30578
Blocks:
  Show dependency treegraph
 
Reported: 2022-10-13 21:35 UTC by David Nind
Modified: 2023-06-08 22:28 UTC (History)
4 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:
22.11.00
Circulation function:


Attachments
Bug 31782: Fix patron autocomplete on patron list (2.80 KB, patch)
2022-11-11 11:26 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 31782: Fix patron autocomplete on order search (2.86 KB, patch)
2022-11-11 11:26 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 31782: Fix autocomplete when duplicating orders (3.19 KB, patch)
2022-11-11 11:26 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 31782: Remove js/autocomplete/patrons.js (3.48 KB, patch)
2022-11-11 11:26 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 31782: Fix patron autocomplete on patron list (2.84 KB, patch)
2022-11-11 11:42 UTC, David Nind
Details | Diff | Splinter Review
Bug 31782: Fix patron autocomplete on order search (2.91 KB, patch)
2022-11-11 11:42 UTC, David Nind
Details | Diff | Splinter Review
Bug 31782: Fix autocomplete when duplicating orders (3.24 KB, patch)
2022-11-11 11:42 UTC, David Nind
Details | Diff | Splinter Review
Bug 31782: Remove js/autocomplete/patrons.js (3.53 KB, patch)
2022-11-11 11:42 UTC, David Nind
Details | Diff | Splinter Review
Bug 31782: Fix patron autocomplete on patron list (2.90 KB, patch)
2022-11-13 13:23 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 31782: Fix patron autocomplete on order search (2.96 KB, patch)
2022-11-13 13:23 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 31782: Fix autocomplete when duplicating orders (3.29 KB, patch)
2022-11-13 13:23 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 31782: Remove js/autocomplete/patrons.js (3.58 KB, patch)
2022-11-13 13:23 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 David Nind 2022-10-13 21:35:27 UTC
When adding a patron to a list, the autocomplete search does not work.

Instead, you have to paste the patron card number or borrower number into the Add multiple patrons form.

To replicate:
1. Go to Tools > Patrons and circulation > Patron lists.
2. Add a new patron list.
3. Go to add patrons page for the list. Note that there is a JavaScript in the web developer tools console [1].
4. Type an existing name in the patron search box, for example: mary. 
5. Note that the progress icon/circle appears very briefly, but the name is not autocompeleted.
6. Note also that there is a 400 bad request error in the web developer tools console.[2]

[1] JavaScript error when viewing Add patrons page for a patron list:

Uncaught TypeError: can't access property "_renderItem", $(...).autocomplete(...).data(...) is undefined
    patron_autocomplete http://127.0.0.1:8081/intranet-tmpl/js/autocomplete/patrons_22.0600062.js:20
    <anonymous> http://127.0.0.1:8081/cgi-bin/koha/patron_lists/list.pl?patron_list_id=1:1080
    jQuery 2
        e
        t

[2] 400 bad request error when typing a name in the autocomplete field:

GET http://127.0.0.1:8081/api/v1/patrons?term=mary
    Status: 400 Bad Request
    Version:  HTTP/1.1
..
Comment 1 Martin Renvoize (ashimema) 2022-10-14 09:11:45 UTC
This feels related to bug 30578..
Comment 2 Jonathan Druart 2022-11-11 11:26:27 UTC
Created attachment 143778 [details] [review]
Bug 31782: Fix patron autocomplete on patron list

Test plan:
Add new patrons to a patron list
Comment 3 Jonathan Druart 2022-11-11 11:26:31 UTC
Created attachment 143779 [details] [review]
Bug 31782: Fix patron autocomplete on order search

Test plan:
Search for order using the "Basket created by" field
Comment 4 Jonathan Druart 2022-11-11 11:26:36 UTC
Created attachment 143780 [details] [review]
Bug 31782: Fix autocomplete when duplicating orders

Test plan:
Add a new order to a basket from an existing order
Search for the order to duplicate using the "Basket created by" field
Comment 5 Jonathan Druart 2022-11-11 11:26:40 UTC
Created attachment 143781 [details] [review]
Bug 31782: Remove js/autocomplete/patrons.js

On 30578 we replace circ/ysearch.pl with a call to the /api/v1/patrons
route. A new patron_autocomplete JS function has been written
(js/patron-autocomplete.js) for that purpose.

However 3 occurrences were using an existing patron_autocomplete
function, and 30578 didn't take care of adjusting correctly the call to
the REST API route.

On this patchset I am suggesting to copy/paste the JS functions defined
in js/autocomplete/patrons.js, because we are very close of the 22.11
release. But ideally we should improve js/patron-autocomplete.js to add
a new 'on-select-add-to' option that will take care of add/remove/hide
behaviour. IMO that must be done on a separate bug, and after 22.11 is
released (to not need to retest the other occurrences of the patron
autocomplete)
Comment 6 Jonathan Druart 2022-11-11 11:32:35 UTC
(In reply to Jonathan Druart from comment #5)
> On this patchset I am suggesting to copy/paste the JS functions defined
> in js/autocomplete/patrons.js, because we are very close of the 22.11
> release. But ideally we should improve js/patron-autocomplete.js to add
> a new 'on-select-add-to' option that will take care of add/remove/hide
> behaviour. IMO that must be done on a separate bug, and after 22.11 is
> released (to not need to retest the other occurrences of the patron
> autocomplete)

See bug 32176.
Comment 7 David Nind 2022-11-11 11:42:12 UTC
Created attachment 143782 [details] [review]
Bug 31782: Fix patron autocomplete on patron list

Test plan:
Add new patrons to a patron list

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 David Nind 2022-11-11 11:42:17 UTC
Created attachment 143783 [details] [review]
Bug 31782: Fix patron autocomplete on order search

Test plan:
Search for order using the "Basket created by" field

Signed-off-by: David Nind <david@davidnind.com>
Comment 9 David Nind 2022-11-11 11:42:23 UTC
Created attachment 143784 [details] [review]
Bug 31782: Fix autocomplete when duplicating orders

Test plan:
Add a new order to a basket from an existing order
Search for the order to duplicate using the "Basket created by" field

Signed-off-by: David Nind <david@davidnind.com>
Comment 10 David Nind 2022-11-11 11:42:28 UTC
Created attachment 143785 [details] [review]
Bug 31782: Remove js/autocomplete/patrons.js

On 30578 we replace circ/ysearch.pl with a call to the /api/v1/patrons
route. A new patron_autocomplete JS function has been written
(js/patron-autocomplete.js) for that purpose.

However 3 occurrences were using an existing patron_autocomplete
function, and 30578 didn't take care of adjusting correctly the call to
the REST API route.

On this patchset I am suggesting to copy/paste the JS functions defined
in js/autocomplete/patrons.js, because we are very close of the 22.11
release. But ideally we should improve js/patron-autocomplete.js to add
a new 'on-select-add-to' option that will take care of add/remove/hide
behaviour. IMO that must be done on a separate bug, and after 22.11 is
released (to not need to retest the other occurrences of the patron
autocomplete)

Signed-off-by: David Nind <david@davidnind.com>
Comment 11 Katrin Fischer 2022-11-13 13:23:21 UTC
Created attachment 143806 [details] [review]
Bug 31782: Fix patron autocomplete on patron list

Test plan:
Add new patrons to a patron list

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 12 Katrin Fischer 2022-11-13 13:23:26 UTC
Created attachment 143807 [details] [review]
Bug 31782: Fix patron autocomplete on order search

Test plan:
Search for order using the "Basket created by" field

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 13 Katrin Fischer 2022-11-13 13:23:31 UTC
Created attachment 143808 [details] [review]
Bug 31782: Fix autocomplete when duplicating orders

Test plan:
Add a new order to a basket from an existing order
Search for the order to duplicate using the "Basket created by" field

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 14 Katrin Fischer 2022-11-13 13:23:36 UTC
Created attachment 143809 [details] [review]
Bug 31782: Remove js/autocomplete/patrons.js

On 30578 we replace circ/ysearch.pl with a call to the /api/v1/patrons
route. A new patron_autocomplete JS function has been written
(js/patron-autocomplete.js) for that purpose.

However 3 occurrences were using an existing patron_autocomplete
function, and 30578 didn't take care of adjusting correctly the call to
the REST API route.

On this patchset I am suggesting to copy/paste the JS functions defined
in js/autocomplete/patrons.js, because we are very close of the 22.11
release. But ideally we should improve js/patron-autocomplete.js to add
a new 'on-select-add-to' option that will take care of add/remove/hide
behaviour. IMO that must be done on a separate bug, and after 22.11 is
released (to not need to retest the other occurrences of the patron
autocomplete)

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 15 Tomás Cohen Arazi (tcohen) 2022-11-14 12:22:25 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 16 Katrin Fischer 2022-11-16 22:59:09 UTC
*** Bug 32015 has been marked as a duplicate of this bug. ***