Bug 27732 - JavaScript error on place hold page in the staff interface
Summary: JavaScript error on place hold page in the staff interface
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Hold requests (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on: 27016
Blocks: 27733
  Show dependency treegraph
 
Reported: 2021-02-19 13:48 UTC by Owen Leonard
Modified: 2021-02-25 09:51 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
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


Attachments
Bug 27732: JavaScript error on place hold page in the staff interface (2.02 KB, patch)
2021-02-19 14:37 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 27732: JavaScript error on place hold page in the staff interface (2.07 KB, patch)
2021-02-19 22:17 UTC, David Nind
Details | Diff | Splinter Review
Bug 27732: JavaScript error on place hold page in the staff interface (2.13 KB, patch)
2021-02-22 15:58 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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