Bugzilla – Attachment 33197 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
Bug-12944-Refactor-the-patron-autocomplete.patch (text/plain), 5.53 KB, created by
Jonathan Druart
on 2014-11-04 14:06:25 UTC
(
hide
)
Description:
Bug 12944: Refactor the patron autocomplete
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-11-04 14:06:25 UTC
Size:
5.53 KB
patch
obsolete
>From 776e4c2969951fabaceda0bb3e0ffbd53c1b32be 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] 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> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Bug 12944 [QA Followup] - Rename patrons.pl to patrons.js > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > koha-tmpl/intranet-tmpl/js/autocomplete/patrons.js | 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.js > >diff --git a/koha-tmpl/intranet-tmpl/js/autocomplete/patrons.js b/koha-tmpl/intranet-tmpl/js/autocomplete/patrons.js >new file mode 100644 >index 0000000..fa041b0 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/js/autocomplete/patrons.js >@@ -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..32d7580 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.js"></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> > >-- >2.1.0
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