Bug 28169 - Reverting waiting hold causes holds page Javascript stop functioning
Summary: Reverting waiting hold causes holds page Javascript stop functioning
Status: Pushed to master
Alias: None
Product: Koha
Classification: Unclassified
Component: Hold requests (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Andrew Nugged
QA Contact: Testopia
URL:
Keywords:
Depends on: 27069
Blocks:
  Show dependency treegraph
 
Reported: 2021-04-19 09:56 UTC by Andrew Nugged
Modified: 2021-04-30 09:26 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Text to go in the release notes:
Version(s) released in:
21.05.00


Attachments
Bug 28169: Add quotes around value in template to render proper JS (2.20 KB, patch)
2021-04-19 13:08 UTC, Andrew Nugged
Details | Diff | Splinter Review
Bug 28169: Add quotes around value in template to render proper JS (2.25 KB, patch)
2021-04-20 14:45 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 28169: Add quotes around value in template to render proper JS (2.31 KB, patch)
2021-04-27 13:59 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 Andrew Nugged 2021-04-19 09:56:48 UTC
There is code in request.tt:

    homebranch: "[% To.json( Branches.GetName( itemloo.homebranch ) ) | $raw %]",
    holdallowed: [% itemloo.holdallowed | html %]

which earlier rendered itemloo.holdallowed ony digits for itemloo.holdallowed but now it has string, for example 'from_any_library', so it should be in quotes now.

To reproduce the problem:
1. Add circulation rules which allow 1 hold to the itemtype
2. Make 1 hold to patron
3. Make sure AllowHoldPolicyOverride syspref enabled
4. Make hold waiting and click revert button, you should see now JS error

I am providing a fix today.
Comment 1 Andrew Nugged 2021-04-19 13:08:06 UTC
Created attachment 119853 [details] [review]
Bug 28169: Add quotes around value in template to render proper JS

There is code in request.tt:

    homebranch: "[% ... %]",
    holdallowed: [% ... %]

There only digits where expected earlier in holdallowed
but now it can be string value ('from_any_library' for example),
so it should be in quotes.

To reproduce the problem:
1. Add circulation rules which allow 1 hold only to the itemtype
2. Make sure AllowHoldPolicyOverride syspref enabled
3. Make 1 hold to patron for any biblio which has a few items available,
   for example on "reset_all dev db set":
   /cgi-bin/koha/reserve/request.pl?biblionumber=4&findborrower=1
   (this biblio record has 4 items)
4. Start another hold for same patron on any biblio record or the same,
   and keep browser's JS console open, 
   for example on "reset_all dev db set":
   /cgi-bin/koha/reserve/request.pl?biblionumber=4&findborrower=1
5. You should see now JS error in browser console:
   Uncaught ReferenceError: from_any_library is not defined
   Uncaught ReferenceError: columns_settings_borrowers_table is not defined
6. Apply the patch
7. Repeat the steps 4-5 (reload the page) and now the JS error should be gone
Comment 2 Owen Leonard 2021-04-20 14:45:46 UTC
Created attachment 119917 [details] [review]
Bug 28169: Add quotes around value in template to render proper JS

There is code in request.tt:

    homebranch: "[% ... %]",
    holdallowed: [% ... %]

There only digits where expected earlier in holdallowed
but now it can be string value ('from_any_library' for example),
so it should be in quotes.

To reproduce the problem:
1. Add circulation rules which allow 1 hold only to the itemtype
2. Make sure AllowHoldPolicyOverride syspref enabled
3. Make 1 hold to patron for any biblio which has a few items available,
   for example on "reset_all dev db set":
   /cgi-bin/koha/reserve/request.pl?biblionumber=4&findborrower=1
   (this biblio record has 4 items)
4. Start another hold for same patron on any biblio record or the same,
   and keep browser's JS console open,
   for example on "reset_all dev db set":
   /cgi-bin/koha/reserve/request.pl?biblionumber=4&findborrower=1
5. You should see now JS error in browser console:
   Uncaught ReferenceError: from_any_library is not defined
   Uncaught ReferenceError: columns_settings_borrowers_table is not defined
6. Apply the patch
7. Repeat the steps 4-5 (reload the page) and now the JS error should be gone

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 3 Martin Renvoize 2021-04-27 13:59:37 UTC
Created attachment 120235 [details] [review]
Bug 28169: Add quotes around value in template to render proper JS

There is code in request.tt:

    homebranch: "[% ... %]",
    holdallowed: [% ... %]

There only digits where expected earlier in holdallowed
but now it can be string value ('from_any_library' for example),
so it should be in quotes.

To reproduce the problem:
1. Add circulation rules which allow 1 hold only to the itemtype
2. Make sure AllowHoldPolicyOverride syspref enabled
3. Make 1 hold to patron for any biblio which has a few items available,
   for example on "reset_all dev db set":
   /cgi-bin/koha/reserve/request.pl?biblionumber=4&findborrower=1
   (this biblio record has 4 items)
4. Start another hold for same patron on any biblio record or the same,
   and keep browser's JS console open,
   for example on "reset_all dev db set":
   /cgi-bin/koha/reserve/request.pl?biblionumber=4&findborrower=1
5. You should see now JS error in browser console:
   Uncaught ReferenceError: from_any_library is not defined
   Uncaught ReferenceError: columns_settings_borrowers_table is not defined
6. Apply the patch
7. Repeat the steps 4-5 (reload the page) and now the JS error should be gone

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2021-04-27 13:59:56 UTC
Nice catch, Passing QA
Comment 5 Jonathan Druart 2021-04-28 09:17:07 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 6 Fridolin Somers 2021-04-30 09:26:36 UTC
Depends on Bug 27069 not in 20.11.x