Format selector improvements
authorBill Erickson <berick@esilibrary.com>
Sat, 28 May 2011 14:01:43 +0000 (10:01 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 20 Jul 2011 18:37:50 +0000 (14:37 -0400)
Consistent with format icon fall-thru, try mattype first to locate the
list of formats for search selection.  If no mattype configuration is
found, fall through to item_type.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/templates/default/opac/parts/advanced/search.tt2
Open-ILS/web/templates/default/opac/parts/coded_value_selector.tt2
Open-ILS/web/templates/default/opac/parts/searchbar.tt2

index 9f1c949..788b571 100644 (file)
@@ -32,7 +32,7 @@
             <td valign='top'>
                 <strong>[% l("Item Type") %]</strong><br />
                 [%  INCLUDE "default/opac/parts/coded_value_selector.tt2"
-                        attr="mattype" multiple="multiple" size="4"
+                        attr=["mattype", "item_type"] multiple="multiple" size="4"
                         id="adv_global_item_type_basic" %]
             </td>
             <td valign='top'>
index cfcd9a0..92a96ee 100644 (file)
@@ -1,15 +1,28 @@
-[%- name = name || "fi:" _ attr;
-    id = id || attr _ "_selector";
-    values = values || CGI.param(name); -%]
+
+[%- 
+    # If caller passes a list of possible attribute types, 
+    # search all until we find some values
+
+    IF !attr.size; attr = [attr]; END;
+    all_values = [];
+    attr_class = '';
+    FOR attr_class IN attr;
+        all_values = ctx.search_ccvm('ctype', attr_class);
+        IF all_values.size > 0; LAST; END;
+    END;
+    name = name || "fi:" _ attr_class;
+    id = id || attr_class _ "_selector";
+    values = values || CGI.param(name); 
+-%]
+
 <select id='[% id %]' name='[% name %]'[%
     multiple ? ' multiple="multiple"' : '';
     size ? (' size="' _ size _ '"') : ''; %]>
-[%  all_values = ctx.search_ccvm('ctype', attr);
-IF none_ok %]
+[% IF none_ok %]
     <option value=''>[% l('-- Any --') %]</option>
-[% END;
-FOR o IN all_values;
-   |l(o.value) %]
-    <option value='[% o.code %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : '' %]>[_1]</option>
-[%  END; END -%]
+[% END %]
+[% FOR o IN all_values %]
+    <option value='[% o.code %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : '' %]>[% o.value %]</option>
+[%  END -%]
 </select>
+
index a38259f..433ce68 100644 (file)
@@ -48,7 +48,7 @@
         [% UNLESS is_advanced %]
         <tr>
             <td>
-                [% INCLUDE "default/opac/parts/coded_value_selector.tt2" attr="mattype" none_ok=1 %]
+                [% INCLUDE "default/opac/parts/coded_value_selector.tt2" attr=["mattype", "item_type"] none_ok=1 %]
             </td>
             <td>
                 <span id='depth_selector_span'>