Committing initial limit-to-available and sort options on record result page
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 8 Nov 2007 15:37:27 +0000 (15:37 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 8 Nov 2007 15:37:27 +0000 (15:37 +0000)
Also, cleaned up some old code and did some tab cleanup

TODO:
    Automatically re-fire search when limit or sort options are changed
    Add relevance as a sort option
    Add limit to advanced search
    Make limit and sort sticky on advanced search
    Evaluate dropdown labels - i.e. What is clearest to the user in the smallest amount of space?

git-svn-id: svn://svn.open-ils.org/ILS/trunk@8044 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/common/js/opac_utils.js
Open-ILS/web/opac/locale/en-US/opac.dtd
Open-ILS/web/opac/skin/default/css/layout.css
Open-ILS/web/opac/skin/default/js/result_common.js
Open-ILS/web/opac/skin/default/js/rresult.js
Open-ILS/web/opac/skin/default/js/search_bar.js
Open-ILS/web/opac/skin/default/xml/common/statusbar.xml
Open-ILS/web/opac/skin/default/xml/result/filtersort.xml [new file with mode: 0644]

index 2243997..58a63a6 100644 (file)
@@ -35,6 +35,7 @@ var PARAM_LANGUAGE    = 'la';
 var PARAM_TFORM                = 'tf'; /* temporary format for title result pages */
 var PARAM_RDEPTH               = 'rd';
 var PARAM_REDIR                = 're'; /* true if we have been redirected by IP (we're at a real lib) */
+var PARAM_AVAIL     = 'av'; /* limit search results to available items */
 
 /* URL param values (see comments above) */
 var TERM;  
@@ -67,6 +68,7 @@ var SEARCHES;
 var LANGUAGE;
 var TFORM;
 var RDEPTH;
+var AVAIL;
 
 /* cookie values */
 var SBEXTRAS; 
index 57babc1..a9835ba 100644 (file)
@@ -153,42 +153,45 @@ function initParams() {
        LANGUAGE        = cgi.param(PARAM_LANGUAGE);
        TFORM           = cgi.param(PARAM_TFORM);
        RDEPTH  = cgi.param(PARAM_RDEPTH);
+    AVAIL   = cgi.param(PARAM_AVAIL);
 
        /* set up some sane defaults */
-       //if(isNaN(DEPTH))              DEPTH           = 0;
-       if(isNaN(RDEPTH))               RDEPTH  = 0;
-       if(isNaN(OFFSET))               OFFSET  = 0;
-       if(isNaN(COUNT))                COUNT           = 10;
+       //if(isNaN(DEPTH))      DEPTH           = 0;
+       if(isNaN(RDEPTH))       RDEPTH  = 0;
+       if(isNaN(OFFSET))       OFFSET  = 0;
+       if(isNaN(COUNT))        COUNT           = 10;
        if(isNaN(HITCOUNT))     HITCOUNT        = 0;
        if(isNaN(MRID))         MRID            = 0;
-       if(isNaN(RID))                  RID             = 0;
+       if(isNaN(RID))          RID             = 0;
        if(isNaN(ORIGLOC))      ORIGLOC = 0; /* so we know it hasn't been set */
        if(isNaN(AUTHTIME))     AUTHTIME        = 0;
-       if(ADVTERM==null)               ADVTERM = "";
+       if(ADVTERM==null)       ADVTERM = "";
+    if(isNaN(AVAIL))    AVAIL = 0;
 }
 
 function clearSearchParams() {
-       TERM            = null;
-       STYPE           = null;
-       FORM            = null;
-       OFFSET  = 0;
-       HITCOUNT = 0;  
-       ADVTERM  = null;
-       ADVTYPE  = null;
-       MRID            = null;
-       RID             = null;
-       RTYPE           = null;
-       SORT            = null;
-       SORT_DIR = null;
-       RLIST           = null;
-       CALLNUM = null;
-       LITFORM = null;
-       ITEMFORM = null;
-       ITEMTYPE = null;
-       AUDIENCE = null;
-       SEARCHES = null;
-       LANGUAGE = null;
-       RDEPTH  = null;
+       TERM        = null;
+       STYPE       = null;
+       FORM        = null;
+       OFFSET      = 0;
+       HITCOUNT    = 0;  
+       ADVTERM     = null;
+       ADVTYPE     = null;
+       MRID        = null;
+       RID         = null;
+       RTYPE       = null;
+       SORT        = null;
+       SORT_DIR    = null;
+       RLIST       = null;
+       CALLNUM     = null;
+       LITFORM     = null;
+       ITEMFORM    = null;
+       ITEMTYPE    = null;
+       AUDIENCE    = null;
+       SEARCHES    = null;
+       LANGUAGE    = null;
+       RDEPTH      = null;
+    AVAIL       = null;
 }
 
 
@@ -231,6 +234,7 @@ function getAudience() { return AUDIENCE; }
 function getSearches() { return SEARCHES; }
 function getLanguage() { return LANGUAGE; }
 function getRdepth() { return RDEPTH; }
+function getAvail() { return AVAIL; }
 
 
 function findBasePath() {
@@ -377,6 +381,8 @@ function  buildOPACLink(args, slim, ssl) {
                string += _appendParam(SORT,    PARAM_SORT, args, getSort, string);
        if(getSortDir() != null)
                string += _appendParam(SORT_DIR,        PARAM_SORT_DIR, args, getSortDir, string);
+       if(getAvail())
+               string += _appendParam(AVAIL, PARAM_AVAIL, args, getAvail, string);
 
        return string.replace(/\&$/,'').replace(/\?\&/,"?");    
 }
index a8b7f84..5802878 100644 (file)
        "The password must be at least 7 characters in length, 
        contain at least one letter (a-z/A-Z), 
        and contain at least one number.">
+<!ENTITY common.a2z "A to Z">
+<!ENTITY common.z2a "Z to A">
+<!ENTITY common.new2old "Newest to Oldest">
+<!ENTITY common.old2new "Oldest to Newest">
 
 <!ENTITY opac.style.reddish "Reddish">
 
@@ -523,6 +527,8 @@ We recommend that you remove this title from any bookbags it may have been added
 <!ENTITY rdetail.noneAvailable " * There are no copies in this location">
 <!ENTITY rdetail.summary.online "Online Resources">
 
+<!ENTITY result.sort_by "Sort Results by ...">
+<!ENTITY result.limit2avail "Limit to Available">
 <!ENTITY result.info.copies "Available copies / Total copies">
 <!ENTITY result.info.no.items "No items with the selected format were found in this location.">
 <!ENTITY result.info.format.items "Listed below are all items in the catalog with the chosen format.">
index 5a0d463..9f5704b 100644 (file)
@@ -241,4 +241,6 @@ table { border-collapse: collapse; }
     margin: auto;
 }
 
+#opac.result.sort { margin-left: 5px; }
+
 
index 35ba911..6602165 100644 (file)
@@ -78,6 +78,7 @@ function resultCollectSearchIds( type, method, handler ) {
        if(sortdir) args.sort_dir = sortdir;
        if(item_type) args.item_type    = item_type;
        if(item_form) args.item_form    = item_form;
+    if(getAvail()) args.available = 1;
 
 
        if(getAudience()) args.audience  = getAudience().split(/,/);
index c314dfd..c0e150b 100644 (file)
@@ -27,35 +27,9 @@ function rresultDoSearch() {
        rresultCollectIds();
 }
 
-function rresultCachedSearch() {
-
-       /* XXX */
-       return false;
-
-       /*
-       if(!getOffset()) {
-               cookieManager.remove(COOKIE_SRIDS);
-               return false;
-       }
-
-       var data = JSON2js(cookieManager.read(COOKIE_SRIDS));
-       //alert('cached count = ' + data.count);
-
-       if( data && data.ids[getOffset()] != null && 
-               data.ids[resultFinalPageIndex()] != null ) {
-               _rresultHandleIds( data.ids, data.count );
-               return true;
-       }
-
-       return false;
-       */
-}
-
 function rresultCollectIds() {
        var ids;
 
-       if(rresultCachedSearch()) return;
-
        switch(getRtype()) {
 
                case RTYPE_COOKIE:
index 335720d..1679fcf 100644 (file)
@@ -41,6 +41,12 @@ function searchBarInit() {
                attachEvt('common','depthChanged', searchBarSubmit);
        }
 
+    if( (limit = $('opac.result.limit2avail')) ) {
+        if(getAvail()) limit.checked = true;
+        s = getSort()+'.'+getSortDir();
+        if(s.length > 1)
+            setSelector($('opac.result.filters'), s);
+    }
 }
 
 function searchBarSubmit() {
@@ -53,8 +59,6 @@ function searchBarSubmit() {
        var d   = (newSearchDepth != null) ?  newSearchDepth : depthSelGetDepth();
        if(isNaN(d)) d = 0;
 
-       //text = text.replace(/'/,'');
-
        var args = {};
 
        if(SHOW_MR_DEFAULT) {
@@ -70,6 +74,14 @@ function searchBarSubmit() {
        args[PARAM_DEPTH]               = d;
        args[PARAM_FORM]                = _fs.options[_fs.selectedIndex].value;
 
+    if($('opac.result.limit2avail')) {
+        args[PARAM_AVAIL] = ($('opac.result.limit2avail').checked) ? 1 : '';
+        if( (val = getSelectorVal($('opac.result.filters'))) ) {
+            args[PARAM_SORT] = val.split('.')[0]
+            args[PARAM_SORT_DIR] = val.split('.')[1]
+        }
+    }
+
        goTo(buildOPACLink(args));
 }
 
index d67b874..a6462c0 100644 (file)
                                                <span>&status.results;</span> <b id='including_results_location'> </b>
                                        </i>
                                </td>
+                <td align='right'>
+                    <!--#if expr="$OILS_PAGE='rresult.xml'"-->
+                    <!--#include virtual="../result/filtersort.xml" -->
+                    <!--#endif -->
+                </td>
                        </tr>
                </tbody>
        </table>
diff --git a/Open-ILS/web/opac/skin/default/xml/result/filtersort.xml b/Open-ILS/web/opac/skin/default/xml/result/filtersort.xml
new file mode 100644 (file)
index 0000000..d88ddff
--- /dev/null
@@ -0,0 +1,20 @@
+<span>
+    &result.limit2avail;<input type='checkbox' id='opac.result.limit2avail'/>
+    <select id='opac.result.sort'>
+        <option selelted='selected' value=''>&result.sort_by;</option>
+        <optgroup label='&common.title;'>
+            <option id='opac.result.title.a2z' label='&common.a2z;' value='title.asc'>&common.a2z;</option>
+            <option id='opac.result.title.z2a' label='&common.z2a;' value='title.desc'>&common.z2a;</option>
+        </optgroup>
+        <optgroup label='&common.author;'>
+            <option id='opac.result.author.a2z' label='&common.a2z;' value='author.asc'>&common.a2z;</option>
+            <option id='opac.result.author.z2a' label='&common.z2a;' value='author.desc'>&common.z2a;</option>
+        </optgroup>
+        <optgroup label='&common.pubdate;'>
+            <option id='opac.result.pubdate.new2old' label='&common.new2old;' 
+                value='pubdate.desc'>&common.new2old;</option>
+            <option id='opac.result.pubdate.old2new' label='&common.old2new;' 
+                value='pubdate.asc'>&common.old2new;</option>
+        </optgroup>
+    </select>
+</span>