Bug 16115 - JavaScript error on item search form unless NOT_LOAN defined
Summary: JavaScript error on item search form unless NOT_LOAN defined
Status: Pushed to Stable
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL: /cgi-bin/koha/catalogue/itemsearch.pl
Whiteboard:
Keywords:
Depends on:
Blocks: 18047
  Show dependency treegraph
 
Reported: 2016-03-21 18:28 UTC by Owen Leonard
Modified: 2017-02-22 23:10 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 16115: Remove JS error on item search if LOC does not exist (2.20 KB, patch)
2017-01-23 09:06 UTC, Jonathan Druart
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 16115: Remove JS error on item search if LOC does not exist (2.26 KB, patch)
2017-01-30 17:13 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 16115: Remove JS error on item search if NOT_LOAN values do not exist (2.32 KB, patch)
2017-02-03 11:32 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2016-03-21 18:28:02 UTC
In the template for the item search page there is this at line 290:

  { 'type': 'select', 'values': [% notforloans.json %] },

[% notforloans.json %] appears to be undefined, whether the search form has been submitted or not. Viewing source shows this:

  { 'type': 'select', 'values':  },


...and the Firebug console reports this error:

SyntaxError: expected expression, got '}'

/cgi-bin/koha/catalogue/itemsearch.pl

Line 240
Comment 1 Jonathan Druart 2016-03-22 10:12:56 UTC
I don't get this JS error.
Looking at the code, it might appear if items.notforloan is not linked to any authorised values in your default framework. Could you confirm?
Comment 2 Owen Leonard 2016-03-22 14:27:08 UTC
Okay you're right it was an issue with my system: I had no "NOT_LOAN" authorized values! I must have removed them while testing something else.

Should we add a check for this, or assume that no one running a real Koha installation is going to do that?
Comment 3 Jonathan Druart 2016-03-22 15:11:11 UTC
No idea :)
If we care about NOT_LOAN, we should care about others and everywhere.
Comment 4 Claire Gravely 2017-01-20 15:37:08 UTC
I'm seeing the same Syntaxerror as Owen after performing an item search and the results are being displayed below the search options, instead of on a clean page. 

SyntaxError: expected expression, got '}'
/cgi-bin/koha/catalogue/itemsearch.pl

Line 396

This occurs for us when no LOC value is present, which is the case for a number of libraries.

If the library happens to have another custom authorised value, the error does not occur and in another case the use of bsort2 also removed the error.
Comment 5 Jonathan Druart 2017-01-23 09:06:22 UTC
Created attachment 59396 [details] [review]
Bug 16115: Remove JS error on item search if LOC does not exist

If LOC is not present, the item search form will raise a JS error:
SyntaxError: expected expression, got '}'

This patch fixes it by handling this specific case.

Note that the "Status" column is still displayed.

Test plan:
Remove your LOC authorised values
Go on the item search form
=> You will not get the JS error and the "Status" bloc is no longer
displayed. There is no need to display it if empty.
Comment 6 Owen Leonard 2017-01-30 17:13:19 UTC
Created attachment 59659 [details] [review]
[SIGNED-OFF] Bug 16115: Remove JS error on item search if LOC does not exist

If LOC is not present, the item search form will raise a JS error:
SyntaxError: expected expression, got '}'

This patch fixes it by handling this specific case.

Note that the "Status" column is still displayed.

Test plan:
Remove your LOC authorised values
Go on the item search form
=> You will not get the JS error and the "Status" bloc is no longer
displayed. There is no need to display it if empty.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 7 Nick Clemens 2017-02-03 11:32:24 UTC
Created attachment 59874 [details] [review]
Bug 16115: Remove JS error on item search if NOT_LOAN values do not exist

If NOT_LOAN is not present, the item search form will raise a JS error:
SyntaxError: expected expression, got '}'

This patch fixes it by handling this specific case.

Note that the "Status" column is still displayed.

Test plan:
Remove your NOT_LOAN authorised values
Go on the item search form
=> You will not get the JS error and the "Status" bloc is no longer
displayed. There is no need to display it if empty.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 8 Nick Clemens 2017-02-03 11:42:33 UTC
Fixed commit message - LOC case handled on bug 18047
Comment 9 Kyle M Hall 2017-02-14 13:46:43 UTC
Pushed to master for 17.05, thanks Jonathan!
Comment 10 Katrin Fischer 2017-02-14 19:26:43 UTC
This patch has been pushed to 16.11.x and will be in 16.11.04.
Comment 11 Julian Maurice 2017-02-20 09:11:55 UTC
Pushed to 3.22.x for 3.22.17
Comment 12 Mason James 2017-02-22 23:10:25 UTC
Pushed to 16.05.x, for 16.05.10 release