generic filters in advanced search using SVF
authorsenator <lebbeous@esilibrary.com>
Wed, 27 Apr 2011 19:53:52 +0000 (15:53 -0400)
committersenator <lebbeous@esilibrary.com>
Wed, 27 Apr 2011 19:53:52 +0000 (15:53 -0400)
incidentally, this reveals that my database has some *weird* languages
represented in it

Open-ILS/web/templates/default/opac/parts/advanced/search.tt2
Open-ILS/web/templates/default/opac/parts/audience_selector.tt2 [deleted file]
Open-ILS/web/templates/default/opac/parts/coded_value_selector.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/opac/parts/format_selector.tt2 [deleted file]
Open-ILS/web/templates/default/opac/parts/language_selector.tt2 [deleted file]
Open-ILS/web/templates/default/opac/parts/searchbar.tt2

index 433b438..9f1c949 100644 (file)
           <table cellpadding='10' cellspacing='0' border='0'><tr>
             <td valign='top'>
                 <strong>[% l("Item Type") %]</strong><br />
-                [%  INCLUDE "default/opac/parts/format_selector.tt2"
-                        multiple="multiple" size="4"
+                [%  INCLUDE "default/opac/parts/coded_value_selector.tt2"
+                        attr="mattype" multiple="multiple" size="4"
                         id="adv_global_item_type_basic" %]
             </td>
             <td valign='top'>
                 <strong>[% l("Language") %]</strong><br />
-                [%  INCLUDE "default/opac/parts/language_selector.tt2"
-                        multiple="multiple" size="4" %]
+                [%  INCLUDE "default/opac/parts/coded_value_selector.tt2"
+                        attr="item_lang" multiple="multiple" size="4" %]
             </td>
             <td valign='top'>
                 <strong>[% l("Audience") %]</strong><br />
-                    [% INCLUDE "default/opac/parts/audience_selector.tt2"
-                        id="adv_global_audience_basic"
+                    [% INCLUDE "default/opac/parts/coded_value_selector.tt2"
+                        attr="audience" id="adv_global_audience_basic" 
                         multiple="multiple" size="4" %]
                 </select>
                     <!--<a id='adv_global_audience_link_adv' class='classic_link adv_adv_link'
diff --git a/Open-ILS/web/templates/default/opac/parts/audience_selector.tt2 b/Open-ILS/web/templates/default/opac/parts/audience_selector.tt2
deleted file mode 100644 (file)
index b3e86bf..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-[%  name = name || "fi:audience";
-    id = id || "audience_selector";
-    values = values || CGI.param(name) %]
-<select id='[% id %]' name='[% name %]'[%
-    multiple ? ' multiple="multiple"' : '';
-    size ? (' size="' _ size _ '"') : ''; %]>
-[%
-FOR opt IN [
-    {'code' => 'a,b,c,j', 'label' => l("Juvenile")},
-    {'code' => 'd', 'label' => l("General")},
-    {'code' => 'e', 'label' => l("Adult")}
-];
-    |l(opt.code, opt.label) %]
-<option value='[_1]'[% values.grep('^' _ opt.code _ '$').size ? ' selected="selected"' : '' %]>[_2]</option>
-[% END; END %]
-</select>
diff --git a/Open-ILS/web/templates/default/opac/parts/coded_value_selector.tt2 b/Open-ILS/web/templates/default/opac/parts/coded_value_selector.tt2
new file mode 100644 (file)
index 0000000..a78edfd
--- /dev/null
@@ -0,0 +1,15 @@
+[%- name = name || "fi:" _ attr;
+    id = id || attr _ "_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 %]
+    <option>[% 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 -%]
+</select>
diff --git a/Open-ILS/web/templates/default/opac/parts/format_selector.tt2 b/Open-ILS/web/templates/default/opac/parts/format_selector.tt2
deleted file mode 100644 (file)
index d52129b..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-[% 
-    # Start w/ mattype, fall back to item_type
-    format_spec = '';
-    formats = [];
-    FOR format_spec IN ['mattype', 'item_type'];
-        formats = ctx.search_ccvm('ctype', format_spec);
-        IF formats.size; BREAK; END;
-    END;
-    name = name || "fi:" _ format_spec;
-    id = id || "format_selector";
-    values = values || CGI.param(name) 
--%]
-
-<select id='[% id %]' name='[% name %]'[%
-    multiple ? ' multiple="multiple"' : '';
-    size ? (' size="' _ size _ '"') : ''; %]>
-    <option value=''>[% l("All Formats") %]</option>
-
-[% FOR o IN formats %]
-    <option value='[% o.code %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : ''%]>[% o.value %]</option>
-[%- END %]
-<!--
-       <option value='at'>[% l("Books") %]</option>
-       <option value='at-d'>[% l("Large Print Books") %]</option>
-       <option value='i'>[% l("Audiobooks") %]</option>
-       <option value='g'>[% l("Video Recordings") %]</option>
-       <option value='j'>[% l("Music") %]</option>
-       <option value='m'>[% l("Electronic Resources") %]</option>
--->
-</select>
diff --git a/Open-ILS/web/templates/default/opac/parts/language_selector.tt2 b/Open-ILS/web/templates/default/opac/parts/language_selector.tt2
deleted file mode 100644 (file)
index 6bdfffe..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-[%- name = name || "fi:language";
-    id = id || "language_selector";
-    values = values || CGI.param(name); -%]
-<select id='[% id %]' name='[% name %]'[%
-    multiple ? ' multiple="multiple"' : '';
-    size ? (' size="' _ size _ '"') : ''; %]>
-[%-
-# Language otions for languages that exist in the catalog.
-# This file should be updated on occasion.
-#
-# develooper=# select code,value from config.language_map m
-#   join metabib.rec_descriptor r on (r.item_lang = m.code) group by 1,2;
-
-# XXX I haven't internationalized these labels because this stuff shouldn't
-# be hardcoded like this forever.
-FOR lang IN [
-    {'code' => 'eng', 'label' => 'English'},
-    {'code' => 'spa', 'label' => 'Spanish'},
-    {'code' => 'fre', 'label' => 'French'},
-    {'code' => 'ger', 'label' => 'German'},
-    {'code' => 'ita', 'label' => 'Italian'},
-    {'code' => 'chi', 'label' => 'Chinese'},
-    {'code' => 'jpn', 'label' => 'Japanese'},
-    {'code' => 'kor', 'label' => 'Korean'},
-    {'code' => 'dut', 'label' => 'Dutch'},
-    {'code' => 'gre', 'label' => 'Greek, Modern (1453- )'},
-    {'code' => 'lat', 'label' => 'Latin'},
-    {'code' => 'vie', 'label' => 'Vietnamese'},
-    {'code' => 'rus', 'label' => 'Russian'},
-    {'code' => 'nor', 'label' => 'Norwegian'},
-    {'code' => 'wel', 'label' => 'Welsh'},
-    {'code' => 'pau', 'label' => 'Palauan'},
-    {'code' => 'swe', 'label' => 'Swedish'},
-    {'code' => 'nav', 'label' => 'Navajo'},
-    {'code' => 'und', 'label' => 'Undetermined'}
-];
-    |l(lang.code, lang.label) %]
-<option value='[_1]'[% values.grep('^' _ lang.code _ '$').size ? ' selected="selected"' : '' %]>[_2]</option>
-[%  END; END -%]
-</select>
index 4be2b14..a38259f 100644 (file)
@@ -48,7 +48,7 @@
         [% UNLESS is_advanced %]
         <tr>
             <td>
-                [% INCLUDE "default/opac/parts/format_selector.tt2" value=CGI.param("format") %]
+                [% INCLUDE "default/opac/parts/coded_value_selector.tt2" attr="mattype" none_ok=1 %]
             </td>
             <td>
                 <span id='depth_selector_span'>