From d6fd2d6bda6c11524ab88238d706606e16b12442 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 3 Feb 2017 11:38:53 +0000 Subject: [PATCH] Bug 18047 - JavaScript error on item search form unless LOC defined 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 "Shelving location" bloc is no longer displayed. There is no need to display it if empty. --- .../prog/en/modules/catalogue/itemsearch.tt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt index d2b0d7f..e88d774 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt @@ -293,7 +293,11 @@ { 'type': 'text' }, { 'type': 'select', 'values': [% branches.json %] }, { 'type': 'select', 'values': [% branches.json %] }, - { 'type': 'select', 'values': [% locations.json %] }, + [% IF locations.size %] + { 'type': 'select', 'values': [% locations.json %] }, + [% ELSE %] + null, + [% END %] { 'type': 'text' }, [% IF notforloans.size %] { 'type': 'select', 'values': [% notforloans.json %] }, @@ -401,11 +405,13 @@ options = branches empty_option = "All libraries" %] - [% INCLUDE form_field_select - name="location" - options = locations - empty_option = "All locations" - %] + [% IF locations.size %] + [% INCLUDE form_field_select + name="location" + options = locations + empty_option = "All locations" + %] + [% END %]
[% INCLUDE form_field_select -- 2.1.4