Bug 27732

Summary: JavaScript error on place hold page in the staff interface
Product: Koha Reporter: Owen Leonard <oleonard>
Component: Hold requestsAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: david, fridolin.somers, gmcharlt, martin.renvoize
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This patch fixes the cause of a JavaScript console error ("Uncaught ReferenceError: $ is not defined") when placing a hold using the staff interface. It: - Moves the "$.fn.select2.defaults" definition from the top of the page to the bottom so that jQuery is loaded first. - Improves the display of the dropdown list for the pickup library so that the width is wider.
Version(s) released in:
21.05.00
Bug Depends on: 27016    
Bug Blocks: 27733    
Attachments: Bug 27732: JavaScript error on place hold page in the staff interface
Bug 27732: JavaScript error on place hold page in the staff interface
Bug 27732: JavaScript error on place hold page in the staff interface

Description Owen Leonard 2021-02-19 13:48:47 UTC
If you begin the process of placing a hold on a title which has existing holds, there is an error in the console:

Uncaught ReferenceError: $ is not defined

The "select2.defaults" script block comes before jQuery is loaded.
Comment 1 Owen Leonard 2021-02-19 14:37:33 UTC
Created attachment 117086 [details] [review]
Bug 27732: JavaScript error on place hold page in the staff interface

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.
Comment 2 David Nind 2021-02-19 22:17:11 UTC
Created attachment 117102 [details] [review]
Bug 27732: JavaScript error on place hold page in the staff interface

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>
Comment 3 David Nind 2021-02-19 22:22:51 UTC
Testing notes:
- The console error appeared for me even if no holds had been placed (that is, there were no holds on the item).
- This improves the display of items in the dropdown list. However, if a shorter library name is displayed, some longer library names are still wrapped when the dropdown list is selected (such as Institut Protestant de Théologie), however it is much improved from what it was before.
Comment 4 Martin Renvoize 2021-02-22 15:58:24 UTC
Created attachment 117157 [details] [review]
Bug 27732: JavaScript error on place hold page in the staff interface

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>
Comment 5 Martin Renvoize 2021-02-22 15:59:02 UTC
Works well, QA scripts pass.. a solid improvement.

Passing QA
Comment 6 Jonathan Druart 2021-02-23 12:22:44 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 7 Fridolin Somers 2021-02-25 09:51:19 UTC
Depends on Bug 27016 not in 20.11.x