Bugzilla – Attachment 31824 Details for
Bug 12944
Search for creator of an order
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12944: Refactor the patron autocomplete
0001-Bug-12944-Refactor-the-patron-autocomplete.patch (text/plain), 5.51 KB, created by
Paola Rossi
on 2014-09-23 09:25:13 UTC
(
hide
)
Description:
Bug 12944: Refactor the patron autocomplete
Filename:
MIME Type:
Creator:
Paola Rossi
Created:
2014-09-23 09:25:13 UTC
Size:
5.51 KB
patch
obsolete
>From 8d432d5c48197df63d350e2a389e2fafe013e959 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 17 Sep 2014 17:12:42 +0200 >Subject: [PATCH 1/2] Bug 12944: Refactor the patron autocomplete > >The patron list feature uses an autocomplete field to search patron. >This will be reused in the next patch. >This patch should not introduce any behavior change. > >Signed-off-by: Paola Rossi <paola.rossi@cineca.it> >--- > koha-tmpl/intranet-tmpl/js/autocomplete/patrons.pl | 48 ++++++++++++++++++++ > .../prog/en/modules/patron_lists/list.tt | 41 ++--------------- > 2 files changed, 53 insertions(+), 36 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/js/autocomplete/patrons.pl > >diff --git a/koha-tmpl/intranet-tmpl/js/autocomplete/patrons.pl b/koha-tmpl/intranet-tmpl/js/autocomplete/patrons.pl >new file mode 100644 >index 0000000..fa041b0 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/js/autocomplete/patrons.pl >@@ -0,0 +1,48 @@ >+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: "/cgi-bin/koha/circ/ysearch.pl", >+ 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.surname, field, patron_container, patron_input_name ); >+ input_autocomplete.val('').focus(); >+ return false; >+ } >+ }) >+ .data( "ui-autocomplete" )._renderItem = function( ul, item ) { >+ return $( "<li></li>" ) >+ .data( "ui-autocomplete-item", item ) >+ .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" ) >+ .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 = "<div id='borrower_" + value + "'>" + patron_name + " ( <a href='#' class='removePatron'> " + _("Remove") + " </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().hide( 800 ); >+ } >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt >index b55da33..67bf9e3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt >@@ -6,6 +6,7 @@ > <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> > [% INCLUDE 'datatables.inc' %] > >+<script type="text/javascript" src="[% interface %]/js/autocomplete/patrons.pl"></script> > <script type="text/javascript"> > //<![CDATA[ > $(document).ready(function() { >@@ -20,26 +21,10 @@ $(document).ready(function() { > ] > } )); > >- $( "#find_patron" ).autocomplete({ >- source: "/cgi-bin/koha/circ/ysearch.pl", >- minLength: 3, >- select: function( event, ui ) { >- AddPatron( ui.item.firstname + " " + ui.item.surname, ui.item.cardnumber ); >- return false; >- } >- }) >- .data( "ui-autocomplete" )._renderItem = function( ul, item ) { >- return $( "<li></li>" ) >- .data( "ui-autocomplete-item", item ) >- .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" ) >- .appendTo( ul ); >- }; >- >- $("body").on("click",".removePatron",function(e){ >- e.preventDefault(); >- var divid = $(this).parent().attr("id"); >- var cardnumber = divid.replace("borrower_",""); >- RemovePatron(cardnumber); >+ patron_autocomplete({ >+ patron_container: $("#patrons_to_add"), >+ input_autocomplete: $("#find_patron"), >+ patron_input_name = 'patrons_to_add' > }); > > var checkBoxes = $("input[type='checkbox']","#patron-list-table"); >@@ -73,22 +58,6 @@ $(document).ready(function() { > }); > }); > >-function AddPatron( name, cardnumber ) { >- div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' class='removePatron'> " + _("Remove") + " </a> ) <input type='hidden' name='patrons_to_add' value='" + cardnumber + "' /></div>"; >- $('#patrons_to_add').append( div ); >- >- $('#find_patron').val('').focus(); >- >- $('#patrons_to_add_fieldset').show( 800 ); >-} >- >-function RemovePatron( cardnumber ) { >- $( '#borrower_' + cardnumber ).remove(); >- >- if ( ! $('#patrons_to_add').html() ) { >- $('#patrons_to_add_fieldset').hide( 800 ); >- } >-} > //]]> > </script> > >-- >1.7.10.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12944
:
31682
|
31683
|
31824
|
31825
|
31987
|
31988
|
31989
|
32922
|
32931
|
33197
|
33198
|
33199
|
33200
|
34781
|
35589
|
35590
|
35591
|
35592
|
35593
|
35698