Add dept location selector (replaces item type)
authorJeff Godin <jgodin@tadl.org>
Tue, 12 Mar 2013 20:10:40 +0000 (16:10 -0400)
committerJeff Godin <jgodin@tadl.org>
Tue, 12 Mar 2013 20:10:40 +0000 (16:10 -0400)
Add optional item_locations_selector (similar to item_type_selector)
which can be used in place of the item_type_selector in areas where
we would like to use shelving locations and not item type as a
search filter.

This is similar to features which exist in future versions of
Evergreen, and may be a simple intermediate step which is later
replaced.

Triggered by the physical_dept 'ys' at the moment, we have a
hardcoded list of groups of shelving locations. If triggered with an
unknown department, the item_locations_selector defaults to a single
empty entry for all locations.

Signed-off-by: Jeff Godin <jgodin@tadl.org>
templates_tadlskin/opac/parts/item_locations_selector.tt2 [new file with mode: 0644]
templates_tadlskin/opac/parts/searchbar.tt2

diff --git a/templates_tadlskin/opac/parts/item_locations_selector.tt2 b/templates_tadlskin/opac/parts/item_locations_selector.tt2
new file mode 100644 (file)
index 0000000..f13cb61
--- /dev/null
@@ -0,0 +1,35 @@
+
+[%
+# These are displayed in the order shown
+IF dept == 'ys';
+    item_locations = [
+        { 'code' => '527,571,770,599,771,529,528,530,531,532,598,597,595,596,630', 'value' => 'Juvenile' },
+        { 'code' => '571,597,595', 'value' => 'Juvenile Audiobooks' },
+        { 'code' => '529', 'value' => 'Juvenile Easy' },
+        { 'code' => '528', 'value' => 'Juvenile Easy Plus' },
+        { 'code' => '549', 'value' => 'Puppets' },
+    ];
+ELSE;
+    item_locations = [
+        { 'code' => '', 'value' => 'All' },
+    ];
+END;
+%]
+
+[%-
+    name = "fi:locations";
+    id = "item_locations_selector";
+    values = values || CGI.param(name);
+-%]
+
+<select id='[% id %]' name='[% name %]'[%
+    multiple ? ' multiple="multiple"' : '';
+    size ? (' size="' _ size _ '"') : ''; %]>
+[% IF none_ok %]
+    <option value=''>[% none_label ? none_label : l('-- Any --') %]</option>
+[% END;
+FOR o IN item_locations; %]
+    <option value='[% o.code %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : '' %]>[% o.value | html %]</option>
+[%  END -%]
+</select>
+
index da24ffe..113b146 100644 (file)
     </div>
     <div class="searchbar">
         [%- INCLUDE "opac/parts/qtype_selector.tt2" id="qtype"; %]
-        [%- INCLUDE "opac/parts/item_format_selector.tt2" none_ok=1 none_label=l('All Formats'); %]
+        [%- IF ctx.physical_dept == 'ys' %]
+            [%- INCLUDE "opac/parts/item_locations_selector.tt2" dept='ys'; %]
+        [%- ELSE %]
+            [%- INCLUDE "opac/parts/item_format_selector.tt2" none_ok=1 none_label=l('All Formats'); %]
+        [%- END %]
         [%- INCLUDE build_org_selector show_loc_groups=1 id='location_selector' %]
     </div>
     [% IF ctx.bookbag %]