advanced search results now show an advanced search form...
authorsenator <lebbeous@esilibrary.com>
Wed, 23 Feb 2011 19:11:46 +0000 (14:11 -0500)
committersenator <lebbeous@esilibrary.com>
Wed, 23 Feb 2011 19:11:46 +0000 (14:11 -0500)
for refining your search terms.  The query-type/contains/term rows don't
yet populate, but the rest of the form does. There probably also needs to
be more stylistic consideration.  Still need to improve the translation of
CGI parameters into QP syntax. Still need to do all kinds of things.

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/web/css/skin/default/opac/style.css
Open-ILS/web/templates/default/opac/parts/advanced/search.tt2
Open-ILS/web/templates/default/opac/parts/audience_options.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/opac/parts/filtersort.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/opac/parts/format_selector.tt2
Open-ILS/web/templates/default/opac/parts/item_lang_options.tt2
Open-ILS/web/templates/default/opac/parts/result/filtersort.tt2 [deleted file]
Open-ILS/web/templates/default/opac/parts/searchbar.tt2
Open-ILS/web/templates/default/opac/results.tt2

index e294aab..199ef1e 100644 (file)
@@ -48,12 +48,12 @@ sub _prepare_biblio_search {
         $cgi->param('depth') :
         $ctx->{find_aou}->($args->{'org_unit'})->ou_type->depth;
 
-    if ($cgi->param('available')) {
+    if (grep /available/, $cgi->param('modifier')) {
         $query = '#available ' . $query;
     }
 
     if ($cgi->param('format')) {
-        $args->{'format'} = join('', $cgi->param('format'));
+        $query .= ' format(' . join('', $cgi->param('format')) . ')';
     }
 
     if ($cgi->param('lang')) {
@@ -63,24 +63,26 @@ sub _prepare_biblio_search {
     }
 
     if ($cgi->param('audience')) {
-        $query .= ' audience(' . $cgi->param('audience') . ')';
+        $query .= ' audience(' . join(',', $cgi->param('audience')) . ')';
     }
 
     if (defined $cgi->param('sort')) {
-        my $sort = $cgi->param('sort');
-        my $sort_order = $cgi->param('sort_order');
-        $query .= " sort($sort)";
-        $query .= '#' . $sort_order if $sort_order and $sort ne 'rel';
+        my ($axis, $desc) = split /\./, $cgi->param('sort');
+        $query .= " sort($axis)";
+        $query .= '#descending' if $desc;
     }
 
-    if ($cgi->param('pubyear_how') && $cgi->param('pubyear1')) {
-        if ($cgi->param('pubyear_how') eq 'between') {
-            $query .= ' between(' . $cgi->param('pubyear1');
-            $query .= ',' .  $cgi->param('pubyear2') if $cgi->param('pubyear2');
+    if ($cgi->param('pubdate') && $cgi->param('date1')) {
+        if ($cgi->param('pubdate') eq 'between') {
+            $query .= ' between(' . $cgi->param('date1');
+            $query .= ',' .  $cgi->param('date2') if $cgi->param('date2');
             $query .= ')';
+        } elsif ($cgi->param('pubdate') eq 'is') {
+            $query .= ' between(' . $cgi->param('date1') .
+                ',' .  $cgi->param('date1') . ')';  # sic, date1 twice
         } else {
-            $query .= ' ' . $cgi->param('pubyear_how') .
-                '(' . $cgi->param('pubyear1') . ')';
+            $query .= ' ' . $cgi->param('pubdate') .
+                '(' . $cgi->param('date1') . ')';
         }
     }
 
index e47edcc..8577afd 100644 (file)
@@ -931,3 +931,9 @@ div.select-wrapper:hover {
 #opac.result.sort { width: 160px; }
 .renew-summary { font-size: 125%; font-style: italic; margin: 0.5ex 0; }
 .failure-text { margin-left: 4em; font-style: italic; color: #ff0000; }
+.refine-controls { font-size: 125%; padding: 0.5ex 0; }
+#adv_search_refine input[type=text] { border: 1px inset #ccc !important; }
+#adv_search_refine select { border: 1px inset #ccc !important; }
+#adv_search_refine {
+    padding-left: 5em; background-color: #d7d7d7; margin: 2ex 0;
+}
index 0fb4ab1..72ca027 100644 (file)
             <td valign='top'>
                 <strong>[% l("Item Type") %]</strong><br />
                 [%  INCLUDE "default/opac/parts/format_selector.tt2"
-                        value=CGI.param("item_type")
+                        values=CGI.param("format")
                         multiple="multiple" size="4"
                         id="adv_global_item_type_basic" %]
             </td>
             <td valign='top'>
                 <strong>[% l("Language") %]</strong><br />
                 <select multiple='multiple' size='4' name="lang" id='adv_global_lang'>
-                    [% INCLUDE "default/opac/parts/item_lang_options.tt2" %]
+                    [% INCLUDE "default/opac/parts/item_lang_options.tt2"
+                        values=CGI.param("lang") %]
                 </select>
             </td>
             <td valign='top'>
                 <strong>[% l("Audience") %]</strong><br />
-                <!-- XXX this used to be multiple, but when would that be
-                useful? -->
-                <select size='3' name="audience" id='adv_global_audience_basic'>
-                    <option value='abcj'>[% l("Juvenile") %]</option>
-                    <option value='d'>[% l("General") %]</option>
-                    <option value='e'>[% l("Adult") %]</option>
+                <select size='3' name="audience" multiple="multiple"
+                    id='adv_global_audience_basic'>
+                    [% INCLUDE "default/opac/parts/audience_options.tt2"
+                        values=CGI.param("audience") %]
                 </select>
                     <!--<a id='adv_global_audience_link_adv' class='classic_link adv_adv_link'
                         href='javascript:void(0);' onclick='
                         hideMe(this);'>[% l("Basic") %]</a>-->
             </td>
             <td valign='top'>
-            <strong>[% l("Sort Criteria") %]</strong>
+            <strong>[% l("Sort Results") %]</strong>
               <table class='opac-auto-017'>
                 <tr>
                     <td align='center' width='100%'>
-                        <table class='' width='100%'>
-                            <tbody>
-                                <tr>
-                                    <td align=''>
-                                        <select id='adv_global_sort_by' name="sort" onchange="$('adv_global_sort_dir').disabled = !Boolean(this.selectedIndex);">
-                                            <option value='rel'>[% l("Relevance") %]</option>
-                                            <option value='title'>[% l("Title") %]</option>
-                                            <option value='author'>[% l("Author") %]</option>
-                                            <option value='pubdate'>[% l("Publication date") %]</option>
-                                        </select>
-                                    </td>
-                                </tr>
-                                <tr>
-                                    <td>
-                                        <select id='adv_global_sort_dir' name="sort_order" disabled='disabled'>
-                                            <option value='asc'>[% l("Ascending / A to Z") %]</option>
-                                            <option value='desc'>[% l("Descending / Z to A") %]</option>
-                                        </select>
-                                    </td>
-                           <!-- force the enable/disable sort dir code to run -->
-                                </tr>
-                                <tr>
-                                    <td align='center' class="hide_me">
-                                        <span>[% l("Group Formats and Editions") %]</span>
-                                        <input id='adv_group_titles' type='checkbox' />
-                                    </td>
-                                    <td align='center'>
-                                    </td>
-                                </tr>
-                            </tbody>
-                        </table>
+                        [% INCLUDE "default/opac/parts/filtersort.tt2"
+                            value=CGI.param('sort') %]
                     </td>
                 </tr>
               </table>
             <table cellpadding='10' cellspacing='0' border='0'>
                 <tbody>
                     <tr>
-                        <td align='right' class="hide_me">
-                            <span>[% l("Item Form") %]</span>
-                        </td>
-                        <td align='left' class="hide_me">
-                            <select multiple='multiple' size='3' id='adv_global_item_form'>
-                            </select>    
-                        </td>
-                        <td align='right' class="hide_me">
-                            <span>[% l("Literary Form") %]</span>
-                            <a id='adv_global_lit_form_link_adv' class='classic_link adv_adv_link'
-                                href='javascript:void(0);' onclick='
-                                hideMe($("adv_global_lit_form_basic"));
-                                unHideMe($("adv_global_lit_form"));
-                                hideMe(this);
-                                unHideMe($("adv_global_lit_form_link_basic"));
-                                '>[% l("Advanced") %]</a>
-                            <a id='adv_global_lit_form_link_basic' class='hide_me classic_link adv_adv_link'
-                                href='javascript:void(0);' onclick='
-                                unHideMe($("adv_global_lit_form_basic"));
-                                hideMe($("adv_global_lit_form"));
-                                unHideMe($("adv_global_lit_form_link_adv"));
-                                hideMe(this);
-                                '>[% l("Basic") %]</a>
-                        </td>
-                        <td align='left' class="hide_me">
-                            <select multiple='multiple' size='3' id='adv_global_lit_form' class='hide_me'>
-                            </select>    
-                            <select multiple='multiple' size='3' id='adv_global_lit_form_basic'>
-                                <option value='0 '>[% l("Non Fiction") %]</option>
-                                <option value='1'>[% l("Fiction") %]</option>
-                            </select>    
-                        </td>
-                        <td align='right' class="hide_me">
-                            <span>[% l("Bib Level") %]</span>
-                        </td>
-                        <td align='left' class="hide_me">
-                            <select multiple='multiple' size='3' id='adv_global_bib_level'>
-                            </select>    
-                        </td>
-                    </tr>
-                    <tr>
                         <td valign='top'>
                             <strong>[% l("Search Library") %]</strong><br />
                             [% PROCESS "default/opac/parts/org_selector.tt2";
                                 PROCESS build_org_selector name='loc' value=loc %]
                             <div style="position:relative;top:7px;">
-                                <input type='checkbox' name="available" value="1"
-                                    id='opac.result.limit2avail'/>
+                                <input type='checkbox' name="modifier"
+                                value="available"[% CGI.param('modifier').grep('available').size ? ' checked="checked"' : '' %]
+                                    id='opac.result.limit2avail' />
                                 <label style="position:relative;top:-2px;"
                                     for='opac.result.limit2avail'>
                                     [% l("Limit to Available") %]</label>
                         </td>
                         <td valign='top'>
                             <strong>[% l("Publication Year") %]</strong><br />
-                            <select id='adv_global_pub_date_type' name='pubyear_how' onchange='
+                            <select id='adv_global_pub_date_type' name='pubdate' onchange='
                                 if(this.selectedIndex == 3)
                                     unHideMe($("adv_global_pub_date_2_span"));
                                 else
                                     hideMe($("adv_global_pub_date_2_span"));'>
-                                <option value='between' selected='selected'>[% l("Is") %]</option><!-- sic -->
-                                <option value='before'>[% l("Before") %]</option>
-                                <option value='after'>[% l("After") %]</option>
-                                <option value='between'>[% l("Between") %]</option>
+                                    [%  FOR opt IN [
+                                            {"code" => "is", "label" => l("Is")},
+                                            {"code" => "before", "label" => l("Before")},
+                                            {"code" => "after", "label" => l("After")},
+                                            {"code" => "between", "label" => l("Between")}
+                                        ];
+                                            |l(opt.code, opt.label) %]
+                                        <option value="[_1]"[% CGI.param('pubdate') == opt.code ? ' selected="selected"' : '' %]>[_2]</option>
+                                    [%  END; END %]
                             </select>    
                             <div style='margin-top:5px;'>
-                                <input id='adv_global_pub_date_1' name='pubyear1' type='text' size='4' maxlength='4'/>
-                                <span id='adv_global_pub_date_2_span' class='hide_me'>
-                                   [% l("and") %] <input name='pubyear2' id='adv_global_pub_date_2' type='text' size='4' maxlength='4'/>
+                                <input id='adv_global_pub_date_1' name='date1' type='text' size='4' maxlength='4' />
+                                <span id='adv_global_pub_date_2_span' class='[% CGI.param("pubdate") == "between" ? "" : "hide_me" %]'>
+                                   [% l("and") %] <input name='date2' id='adv_global_pub_date_2' type='text' size='4' maxlength='4'/>
                                 </span>
                             </div>
                         </td>
         </td>
     </tr>
 </table>
+<input type="hidden" name="_adv" value="1" />
 </form>
 <div id='adv_quick_search_sidebar' class='sidebar_chunk hide_me'> 
     <div id='adv_quick_search'>
diff --git a/Open-ILS/web/templates/default/opac/parts/audience_options.tt2 b/Open-ILS/web/templates/default/opac/parts/audience_options.tt2
new file mode 100644 (file)
index 0000000..00e7790
--- /dev/null
@@ -0,0 +1,9 @@
+[%
+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 %]
diff --git a/Open-ILS/web/templates/default/opac/parts/filtersort.tt2 b/Open-ILS/web/templates/default/opac/parts/filtersort.tt2
new file mode 100644 (file)
index 0000000..795b179
--- /dev/null
@@ -0,0 +1,15 @@
+<select class="results_header_sel" id='opac.result.sort' name="sort">
+    <option value=''>[% l("Sort by Relevance") %]</option>
+    <optgroup label='[% l("Sort by Title") %]'>
+        <option value='title'[% value == 'title' ? ' selected="selected"' : '' %]>[% l("Title: A to Z") %]</option>
+        <option value='title.desc'[% value == 'title.desc' ? ' selected="selected"' : '' %]>[% l("Title: Z to A") %]</option>
+    </optgroup>
+    <optgroup label='[% l("Sort by Author") %]'>
+        <option value='author'[% value == 'author' ? ' selected="selected"' : '' %]>[% l("Author: A to Z") %]</option>
+        <option value='author.desc'[% value == 'author.desc' ? ' selected="selected"' : '' %]>[% l("Author: Z to A") %]</option>
+    </optgroup>
+    <optgroup label='[% l("Sort by Publication Date") %]'>
+        <option value='pubdate.desc'[% value == 'pubdate.desc' ? ' selected="selected"' : '' %]>[% l("Date: Newest to Oldest") %]</option>
+        <option value='pubdate'[% value == 'pubdate' ? ' selected="selected"' : '' %]>[% l("Date: Oldest to Newest") %]</option>
+    </optgroup>
+</select>
index a93a4ad..d9fcddd 100644 (file)
@@ -5,7 +5,7 @@
     size ? (' size="' _ size _ '"') : ''; %]>
     <option value=''>[% l("All Formats") %]</option>
 [% FOR o IN formats %]
-    <option value='[% o.code %]'[% value == o.code ? ' selected="selected"' : ''%]>[% o.name %]</option>
+    <option value='[% o.code %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : ''%]>[% o.name %]</option>
 [%- END %]
 <!--
        <option value='at'>[% l("Books") %]</option>
index 90ee666..d44b21c 100644 (file)
@@ -1,28 +1,33 @@
+[%
+# 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;
 
-<!--
-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;
--->
-
-<option value='eng'>English</option>
-<option value='spa'>Spanish</option>
-<option value='fre'>French</option>
-<option value='ger'>German</option>
-<option value='ita'>Italian</option>
-<option value='chi'>Chinese</option>
-<option value='jpn'>Japanese</option>
-<option value='kor'>Korean</option>
-<option value='dut'>Dutch</option>
-<option value='gre'>Greek, Modern (1453- )</option>
-<option value='lat'>Latin</option>
-<option value='vie'>Vietnamese</option>
-<option value='rus'>Russian</option>
-<option value='nor'>Norwegian</option>
-<option value='wel'>Welsh</option>
-<option value='pau'>Palauan</option>
-<option value='swe'>Swedish</option>
-<option value='nav'>Navajo</option>
-<option value='und'>Undetermined</option>
+# 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 %]
diff --git a/Open-ILS/web/templates/default/opac/parts/result/filtersort.tt2 b/Open-ILS/web/templates/default/opac/parts/result/filtersort.tt2
deleted file mode 100644 (file)
index fc59655..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<select class="results_header_sel" id='opac.result.sort' onchange='searchBarSubmit(true);'>
-    <option selected='selected' value=''>[% l("Sort Results by Relevance") %]</option>
-    <optgroup label='[% l("Sort Results by Title") %]'>
-        <option id='opac.result.title.a2z' value='title.asc'>[% l("Title: A to Z") %]</option>
-        <option id='opac.result.title.z2a' lue='title.desc'>[% l("Title: Z to A") %]</option>
-    </optgroup>
-    <optgroup label='[% l("Sort Results by Author") %]'>
-        <option id='opac.result.author.a2z' value='author.asc'>[% l("Author: A to Z") %]</option>
-        <option id='opac.result.author.z2a' value='author.desc'>[% l("Author: Z to A") %]</option>
-    </optgroup>
-    <optgroup label='[% l("Sort Results by Publication Date") %]'>
-        <option id='opac.result.pubdate.new2old' value='pubdate.desc'>[% l("Date: Newest to Oldest") %]</option>
-        <option id='opac.result.pubdate.old2new' value='pubdate.asc'>[% l("Date: Oldest to Newest") %]</option>
-    </optgroup>
-</select>
index e4d157d..3636eb0 100644 (file)
@@ -1,5 +1,22 @@
 [% PROCESS "default/opac/parts/org_selector.tt2" %]
 <div id="search-box">    
+    [% IF CGI.param('_adv') # this means adv search got us here %]
+    <div class="refine-controls">
+        <span id="refine_control_reveal">[
+            <a href="[% ctx.opac_root %]/advanced?[% query_string %]"
+                onclick="unHideMe($('adv_search_refine')); unHideMe($('refine_control_hide')); hideMe($('refine_control_reveal')); return false;">[%
+            l('Click to Refine Your Search')
+        %]</a> ]</span>
+        <span id="refine_control_hide" class="hide_me">[
+            <a href="javascript:void(0);"
+                onclick="hideMe($('adv_search_refine')); hideMe($('refine_control_hide')); unHideMe($('refine_control_reveal')); return false;">[%
+            l('Click to Hide Search Form')
+        %]</a> ]</span>
+    </div>
+    <div id="adv_search_refine" class="hide_me">
+        [% INCLUDE "default/opac/parts/advanced/search.tt2" %]
+    </div>
+    [% ELSE %]
     <form action="[% ctx.opac_root %]/results" method="GET">
     <table cellpadding="0" cellspacing="10" border="0">
         <tr>
@@ -49,6 +66,7 @@
         </tr>
     </table>
     </form>
+    [% END %]
     <div id="breadcrumb">
         <a href="[% ctx.opac_root %]/home">[% l('Catalog Home') %]</a> &gt;
     </div>
index 2bfa7ca..f4f0f71 100644 (file)
                         onmouseout="this.src='[% ctx.media_prefix %]/images/view_my_list.png';" /></a>
                 </div>
                 <div class="results_header_div"></div>
-                <div class="results_header_lbl">Sort by</div>
-                [% INCLUDE "default/opac/parts/result/filtersort.tt2" %]
-                <div class="results_header_div"></div>
-                <!-- XXX still needed?<div class="results_header_lbl">View</div>
-                <select class="results_header_sel">
-                    <option>Simple</option>
-                    <option>Detailed</option>
-                </select>
-                <div class="results_header_div"></div> -->
-                <input type="checkbox" id="limit_to_available" />
-                <label for="limit_to_available" class="results_header_lbl">
-                    [% l('Limit to available items') %]
-                </label>
+                [% UNLESS CGI.param('_adv') %]
+                    <div class="results_header_lbl">Sort by</div>
+                    [% INCLUDE "default/opac/parts/filtersort.tt2" %]
+                    <div class="results_header_div"></div>
+                    <!-- XXX still needed?<div class="results_header_lbl">View</div>
+                    <select class="results_header_sel">
+                        <option>Simple</option>
+                        <option>Detailed</option>
+                    </select>
+                    <div class="results_header_div"></div> -->
+                    <input type="checkbox" id="limit_to_available" />
+                    <label for="limit_to_available" class="results_header_lbl">
+                        [% l('Limit to available items') %]
+                    </label>
+                [% END %]
                 <div class="clear-both"></div>
             </div>
         </div>