Bug 21076: Don't call autocomplete code after patron found
authorNick Clemens <nick@bywatersolutions.com>
Fri, 13 Jul 2018 17:49:14 +0000 (17:49 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 19 Jul 2018 16:16:04 +0000 (16:16 +0000)
To test:
1 - Enable article requests
2 - Search on staff client
3 - Click 'Request article'
4 - Find a patron
5 - View error in console
6 - Apply patch
7 - Reload
8 - Not error is gone

Signed-off-by: Maryse Simard <maryse.simard@inlibro.com>
Followed the test plan and it works.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt

index ca1aa1b..94d9b33 100644 (file)
         });
 
         $(document).ready(function() {
-            $( "#patron" ).autocomplete({
-                source: "/cgi-bin/koha/circ/ysearch.pl",
-                minLength: 3,
-                select: function( event, ui ) {
-                    $( "#patron" ).val( ui.item.cardnumber );
-                    $( "#holds_patronsearch" ).submit();
-                    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 );
-            };
+            [% UNLESS (patron ) %]
+                $( "#patron" ).autocomplete({
+                    source: "/cgi-bin/koha/circ/ysearch.pl",
+                    minLength: 3,
+                    select: function( event, ui ) {
+                        $( "#patron" ).val( ui.item.cardnumber );
+                        $( "#holds_patronsearch" ).submit();
+                        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 );
+                };
+            [% END %]
 
             $( ".ar-update-branchcode" ).on('focus', function(){
                 previous_branchcode = this.value;