From 06833f8fd983fb175740cb9e6f983108bb40a1bb Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 11 Nov 2022 12:17:28 +0100 Subject: [PATCH] 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 --- .../intranet-tmpl/js/autocomplete/patrons.js | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 koha-tmpl/intranet-tmpl/js/autocomplete/patrons.js diff --git a/koha-tmpl/intranet-tmpl/js/autocomplete/patrons.js b/koha-tmpl/intranet-tmpl/js/autocomplete/patrons.js deleted file mode 100644 index 87c65eadc1..0000000000 --- a/koha-tmpl/intranet-tmpl/js/autocomplete/patrons.js +++ /dev/null @@ -1,48 +0,0 @@ -function patron_autocomplete(params) { - var patron_container = params.patron_container; - var input_autocomplete = params.input_autocomplete; - var patron_input_name = params.patron_input_name || 'cardnumber'; - var field_to_retrieve = params.field_to_retrieve || 'cardnumber'; - - $( input_autocomplete ).autocomplete({ - source: "/api/v1/patrons", - minLength: 3, - select: function( event, ui ) { - var field = ui.item.cardnumber; - if ( field_to_retrieve == 'borrowernumber' ) { - field = ui.item.borrowernumber; - } - AddPatron( ui.item.firstname + " " + ui.item.middle_name + " " + ui.item.surname, field, patron_container, patron_input_name ); - input_autocomplete.val('').focus(); - return false; - } - }) - .data( "ui-autocomplete" )._renderItem = function( ul, item ) { - return $( "
  • " ) - .data( "ui-autocomplete-item", item ) - .append( "" + item.surname + ", " + item.firstname + " " + item.middle_name + " (" + item.cardnumber + ") " + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "" ) - .appendTo( ul ); - }; - - $("body").on("click",".removePatron",function(e){ - e.preventDefault(); - var divid = $(this).parent().attr("id"); - var cardnumber = divid.replace("borrower_",""); - RemovePatron(cardnumber, patron_container); - }); -} - -function AddPatron( patron_name, value, container, input_name ) { - div = "
    " + patron_name + " ( " + MSG_REMOVE_PATRON + " )
    "; - $(container).append( div ); - - $(container).parent().show( 800 ); -} - -function RemovePatron( cardnumber, container ) { - $( '#borrower_' + cardnumber ).remove(); - - if ( ! $(container).html() ) { - $(container).parent().hide( 800 ); - } -} -- 2.30.2