From bef18f48a546c8c9d258b93f3d1bb9210ada9d62 Mon Sep 17 00:00:00 2001 From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Date: Mon, 21 Feb 2022 11:56:06 +0100 Subject: [PATCH] Bug 30093: Restore the autocomplete feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Séverine Queune <severine.queune@bulac.fr> --- .../prog/en/modules/reserve/request.tt | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 1e48c1b19a..b9ad43ce46 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1145,6 +1145,12 @@ [% Asset.js("lib/hc-sticky.js") | $raw %] [% INCLUDE 'select2.inc' %] [% Asset.js("js/holds.js") | $raw%] + + [% SET url_biblio_params = "biblionumber=" _ biblionumbers.join("&biblionumber=") %] + [% IF multi_hold %] + [% SET url_biblio_params = url_biblio_params _ "&multi_hold=1" %] + [% END %] + <script> var Sticky; var biblionumbers = [[% biblionumbers.join(', ') | $raw %]]; @@ -1503,6 +1509,40 @@ return false; }); + [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) %] + [% IF ( PatronAutoComplete ) %] + $( "#search_patron_filter" ).autocomplete({ + source: "/cgi-bin/koha/circ/ysearch.pl", + minLength: 3, + select: function( event, ui ) { + document.location.href = '/cgi-bin/koha/reserve/request.pl?[% url_biblio_params | url %]&borrowernumber=' + ui.item.borrowernumber; + } + }) + .data( "ui-autocomplete" )._renderItem = function( ul, item ) { + return $( "<li></li>" ) + .data( "ui-autocomplete-item", item ) + .append( + "<a>" + + ( item.surname ? item.surname.escapeHtml() : "" ) + + ", " + + ( item.firstname ? item.firstname.escapeHtml() : "" ) + + " (" + ( item.cardnumber ? item.cardnumber.escapeHtml() : "" ) + ")" + + " " + + "<small>" + + ( item.address ? item.address.escapeHtml() : "" ) + + " " + + ( item.city ? item.city.escapeHtml() : "" ) + + " " + + ( item.zipcode ? item.zipcode.escapeHtml() : "" ) + + " " + + ( item.country ? item.country.escapeHtml() : "" ) + + "</small>" + + "</a>" ) + .appendTo( ul ); + }; + [% END %] + [% END %] + Sticky = $("#toolbar"); Sticky.hcSticky({ stickTo: "#existing_holds", @@ -1560,11 +1600,6 @@ table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]; </script> - [% SET url_biblio_params = "biblionumber=" _ biblionumbers.join("&biblionumber=") %] - [% IF multi_hold %] - [% SET url_biblio_params = url_biblio_params _ "&multi_hold=1" %] - [% END %] - [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, -- 2.20.1