Bug 30578: Remove circ/ysearch.pl in favor of the /patrons REST API route
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 9 Jun 2022 09:03:27 +0000 (11:03 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 18 Jul 2022 14:01:34 +0000 (11:01 -0300)
commit9309dedb53dd73b7e129db2acde37d2cf55aff51
treebefbbbc4031afcaeab19d730969401c31311dc6b
parente25819723d5b1e99e2334f4b00adafb0a5134eae
Bug 30578: Remove circ/ysearch.pl in favor of the /patrons REST API route

This patch removes the circ/ysearch.pl script used by the jQuery autocomplete widget.
We can now use the /api/v1/patrons endpoint to retrieve the patrons and
generate the patron result list.

Prior to this patch the different occurrences were defining the style
and the list of patron's attributes to display for each option (name,
date of birth, age, address, etc.). Now they are all displaying the same
information.

To acchieve this we had to:
* Make js-date-format.inc and js-patron-get-age.inc available from js_includes.inc
and so available from everywhere, which is certainly a good move. We
could discuss why this code is in include file instead of JS files
however.
* Remove the .ajaxSetup call in tags-review.js to reduce its scope: an
underscore parameter was added to the REST API query (?)

A better solution would have been to extend the existing widget
(https://learn.jquery.com/jquery-ui/widget-factory/extending-widgets/)
but I didn't manage to do it, and I feel like there is a bug in jQuery
autocomplete. The "source" was not taken into account.
We could think about replacing the jQuery autocomplete with something
else, but that's outside the scope of this bug.

Test plan:
Search for patrons and confirm the autocomplete works and that the
"select" action works as before (either a redirect or select the
patrons) on the different views:
* Place a hold
* Search for tags (form on the left)
* In the header, "Check out" and "Search patrons"
* Add instructors to course reserves
* View logs (the "librarian" input)

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
15 files changed:
api/v1/swagger/definitions/patron.yaml
api/v1/swagger/paths/patrons.yaml
circ/ysearch.pl [deleted file]
koha-tmpl/intranet-tmpl/js/autocomplete/patrons.js
koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc
koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt
koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt
koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js
koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/js/viewlog.js