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> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
40c052f20e
commit
2360443df6
1 changed files with 27 additions and 6 deletions
|
@ -159,7 +159,6 @@
|
|||
[% INCLUDE 'calendar.inc' %]
|
||||
[% INCLUDE 'datatables.inc' %]
|
||||
[% INCLUDE 'columns_settings.inc' %]
|
||||
[% Asset.js("js/autocomplete/patrons.js") | $raw %]
|
||||
<script>
|
||||
var MSG_REMOVE_PATRON = _("Remove");
|
||||
$(document).ready(function() {
|
||||
|
@ -168,12 +167,34 @@
|
|||
"sPaginationType": "full"
|
||||
}, table_settings );
|
||||
|
||||
patron_autocomplete({
|
||||
patron_container: $("#basket_creators"),
|
||||
input_autocomplete: $("#find_patron"),
|
||||
patron_input_name: 'created_by',
|
||||
field_to_retrieve: 'borrowernumber'
|
||||
function AddPatron( patron_name, value, container, input_name ) {
|
||||
div = "<div id='borrower_" + value + "'>" + patron_name + " ( <a href='#' class='removePatron'><i class='fa fa-trash' aria-hidden='true'></i> " + MSG_REMOVE_PATRON + " </a> ) <input type='hidden' name='" + input_name + "' value='" + value + "' /></div>";
|
||||
$(container).append( div );
|
||||
|
||||
$(container).parent().show( 800 );
|
||||
}
|
||||
function RemovePatron( cardnumber, container ) {
|
||||
$( '#borrower_' + cardnumber ).remove();
|
||||
|
||||
if ( ! $(container).html() ) {
|
||||
$(container).parent("fieldset").hide( 800 );
|
||||
}
|
||||
}
|
||||
patron_autocomplete($("#find_patron"), {
|
||||
'on-select-callback': function( event, ui ) {
|
||||
var field = ui.item.borrowernumber;
|
||||
AddPatron( ui.item.firstname + " " + ( ui.item.middle_name || "" ) + " " + ui.item.surname, field, $("#basket_creators"), 'created_by' );
|
||||
$("#find_patron").val('').focus();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
$("body").on("click",".removePatron",function(e){
|
||||
e.preventDefault();
|
||||
var divid = $(this).parent().attr("id");
|
||||
var cardnumber = divid.replace("borrower_","");
|
||||
RemovePatron(cardnumber, $("#basket_creators"));
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
Loading…
Reference in a new issue