Bug 27732: JavaScript error on place hold page in the staff interface
authorOwen Leonard <oleonard@myacpl.org>
Fri, 19 Feb 2021 14:27:08 +0000 (14:27 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 23 Feb 2021 12:16:07 +0000 (13:16 +0100)
This patch moves the "$.fn.select2.defaults" definition from the top of
the page to the bottom so that jQuery will be loaded first.

The patch also changes the "dropdownAutoWidth" default so that the
dropdown is sized correctly for its contents, regardless of the width of
the initial <select>.

To test, apply the patch and place a hold in the staff interface for a
title which already has existing holds.

- On the "Place a hold" page, before selecting a patron, you should see
  a table of exising holds. Test the "Pickup library" dropdown. It should
  work correctly.
- The width of the dropdown should accommodate its contents without
  forcing any library name to wrap.
- There should be no errors in the browser console.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt

index dc85eff..09e8e66 100644 (file)
@@ -20,9 +20,7 @@
 </head>
 
 <body id="circ_request" class="catalog">
-<script>
-    $.fn.select2.defaults.set("width", "100%" );
-</script>
+
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'circ-search.inc' %]
 
             cannotBeTransferred: _("Cannot be transferred to pickup library")
         }
         columns_settings_borrowers_table = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
+        $.fn.select2.defaults.set("width", "100%" );
+        $.fn.select2.defaults.set("dropdownAutoWidth", true );
 
         $(document).ready(function() {
             $('#cancellation-reason-fieldset').hide();