added sorting interface to the advanced "refined"
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 1 Mar 2006 21:16:32 +0000 (21:16 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 1 Mar 2006 21:16:32 +0000 (21:16 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3231 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/skin/default/js/advanced.js
Open-ILS/web/opac/skin/default/js/mresult.js
Open-ILS/web/opac/skin/default/xml/advanced/advanced_refined.xml
Open-ILS/web/opac/skin/default/xml/advanced/advanced_wizard.xml

index b90e5b3..2b05b10 100644 (file)
@@ -32,10 +32,12 @@ function advInit() {
        setEnterFunc($('opac.advanced.quick.issn'), advISSNRun );
        setEnterFunc( $n( $('advanced.marc.tbody'), 'advanced.marc.value'), advMARCRun );
 
        setEnterFunc($('opac.advanced.quick.issn'), advISSNRun );
        setEnterFunc( $n( $('advanced.marc.tbody'), 'advanced.marc.value'), advMARCRun );
 
+       /*
        setSelector($('advanced.wizard.sort_by'), getSort());
        setSelector($('advanced.wizard.sort_dir'), getSortDir());
        if(getSort() && getSort() != SORT_TYPE_REL) 
                $('advanced.wizard.sort_dir').disabled = false;
        setSelector($('advanced.wizard.sort_by'), getSort());
        setSelector($('advanced.wizard.sort_dir'), getSortDir());
        if(getSort() && getSort() != SORT_TYPE_REL) 
                $('advanced.wizard.sort_dir').disabled = false;
+               */
 }
 
 
 }
 
 
@@ -86,6 +88,8 @@ function advRefinedRun() {
        var subject = $('advanced.refined.subject_contains').value;
        var series      = $('advanced.refined.series_contains').value;
        var form = getSelectorVal($('advanced.refined.form_selector'));
        var subject = $('advanced.refined.subject_contains').value;
        var series      = $('advanced.refined.series_contains').value;
        var form = getSelectorVal($('advanced.refined.form_selector'));
+       var sort                = getSelectorVal($('advanced.refined.sort_by'));
+       var sortdir     = getSelectorVal($('advanced.refined.sort_dir'));
 
        var blob = {};
        title = advRefinedTerm('title', title);
 
        var blob = {};
        title = advRefinedTerm('title', title);
@@ -108,6 +112,8 @@ function advRefinedRun() {
        arg[PARAM_LOCATION]     = depthSelGetNewLoc();
        arg[PARAM_OFFSET]               = 0;
        arg[PARAM_ADVTYPE]      = ADVTYPE_MULTI;
        arg[PARAM_LOCATION]     = depthSelGetNewLoc();
        arg[PARAM_OFFSET]               = 0;
        arg[PARAM_ADVTYPE]      = ADVTYPE_MULTI;
+       arg[PARAM_SORT]         = sort;
+       arg[PARAM_SORT_DIR]     = sortdir;
 
        goTo(buildOPACLink(arg));
 
 
        goTo(buildOPACLink(arg));
 
index c139986..f18d789 100644 (file)
@@ -27,33 +27,6 @@ function mresultDoSearch() {
        while( table.parentNode.rows.length <= (getDisplayCount() + 1) )  
                table.appendChild(G.ui.result.row_template.cloneNode(true));
 
        while( table.parentNode.rows.length <= (getDisplayCount() + 1) )  
                table.appendChild(G.ui.result.row_template.cloneNode(true));
 
-       /*
-       if(getOffset() == 0 || getHitCount() == null ) {
-               if( getAdvTerm() && !getTerm() ) {
-                       if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();
-                       if(getAdvType() == ADVTYPE_MARC ) mresultCollectAdvMARCIds();
-                       if(getAdvType() == ADVTYPE_ISBN ) mresultCollectAdvISBNIds();
-                       if(getAdvType() == ADVTYPE_ISSN ) mresultCollectAdvISSNIds();
-
-               } else {
-                       mresultCollectIds(FETCH_MRIDS_FULL); 
-                       ADVTERM = "";
-                       ADVTYPE = "";
-               }
-
-       } else  {
-               if( getAdvTerm() && !getTerm() ) {
-                       if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();
-                       if(getAdvType() == ADVTYPE_MARC ) mresultCollectAdvIds();
-
-               } else {
-                       mresultCollectIds(FETCH_MRIDS);
-                       ADVTERM = "";
-                       ADVTYPE = "";
-               }
-       }
-       */
-
        if( getAdvTerm() && !getTerm() ) {
                if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();
                if(getAdvType() == ADVTYPE_MARC ) mresultCollectAdvMARCIds();
        if( getAdvTerm() && !getTerm() ) {
                if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();
                if(getAdvType() == ADVTYPE_MARC ) mresultCollectAdvMARCIds();
@@ -85,21 +58,8 @@ function mresultTryCachedSearch() {
        return false;
 }
 
        return false;
 }
 
-
-/* performs the actual search */
-/*
-function mresultCollectIds(method) {
-       if(!mresultTryCachedSearch()) {
-               var form = (getForm() == "all") ? null : getForm();
-               var req = new Request(method, getStype(), getTerm(), 
-                       getLocation(), getDepth(), mresultPreCache, getOffset(), form );
-               req.callback(mresultHandleMRIds);
-               req.send();
-       }
-}
-*/
-
 function _mresultCollectIds() {
 function _mresultCollectIds() {
+
        if( getOffset() == 0 || !mresultTryCachedSearch() ) {
 
                var form                = (!getForm() || getForm() == "all") ? null : getForm();
        if( getOffset() == 0 || !mresultTryCachedSearch() ) {
 
                var form                = (!getForm() || getForm() == "all") ? null : getForm();
@@ -123,10 +83,23 @@ function _mresultCollectIds() {
 
 
 function mresultCollectAdvIds() {
 
 
 function mresultCollectAdvIds() {
-       if(!mresultTryCachedSearch()) {
-               var form = (getForm() == "all") ? null : getForm();
+
+       if(getOffset() == 0 || !mresultTryCachedSearch()) {
+
+               var form                = (getForm() == "all") ? null : getForm();
+               var sort                = (getSort() == SORT_TYPE_REL) ? null : getSort(); 
+               var sortdir = (sort) ? getSortDir() : null;
+
                var req = new Request(FETCH_ADV_MRIDS, 
                var req = new Request(FETCH_ADV_MRIDS, 
-                       JSON2js(getAdvTerm()), getLocation(), form, mresultPreCache );
+                       {       sort            : sort,
+                               sort_dir        : sortdir,
+                               org_unit : getLocation(),
+                               depth           : getDepth(),
+                               limit           : mresultPreCache,
+                               offset  : getOffset(),
+                               format  : form,
+                               searches        : JSON2js(getAdvTerm()) } );
+
                req.callback(mresultHandleMRIds);
                req.send();
        }
                req.callback(mresultHandleMRIds);
                req.send();
        }
@@ -159,10 +132,8 @@ function mresultCollectAdvISSNIds() {
 }
 
 
 }
 
 
-
 function mresultHandleMRIds(r) {
        var res = r.getResultObject();
 function mresultHandleMRIds(r) {
        var res = r.getResultObject();
-
        if(res.count != null) {
                if( getOffset() == 0 ) HITCOUNT = res.count;
                runEvt('result', 'hitCountReceived');
        if(res.count != null) {
                if( getOffset() == 0 ) HITCOUNT = res.count;
                runEvt('result', 'hitCountReceived');
index 71ddea1..454eee0 100644 (file)
@@ -9,7 +9,7 @@
                                <!--#set var='OILS_ADV_CONT_ID' value="advanced.refined.title_type"-->
                                <!--#include virtual="advanced_contains.xml"-->
                        </td>
                                <!--#set var='OILS_ADV_CONT_ID' value="advanced.refined.title_type"-->
                                <!--#include virtual="advanced_contains.xml"-->
                        </td>
-                       <td align='center'>
+                       <td colspan='2' align='center'>
                                <input type='text' size='36' id='advanced.refined.title_contains'> </input>
                        </td>
                </tr>
                                <input type='text' size='36' id='advanced.refined.title_contains'> </input>
                        </td>
                </tr>
@@ -19,7 +19,7 @@
                                <!--#set var='OILS_ADV_CONT_ID' value="advanced.refined.author_type"-->
                                <!--#include virtual="advanced_contains.xml"-->
                        </td>
                                <!--#set var='OILS_ADV_CONT_ID' value="advanced.refined.author_type"-->
                                <!--#include virtual="advanced_contains.xml"-->
                        </td>
-                       <td align='center'>
+                       <td colspan='2' align='center'>
                                <input type='text' size='36' id='advanced.refined.author_contains'> </input>
                        </td>
                </tr>
                                <input type='text' size='36' id='advanced.refined.author_contains'> </input>
                        </td>
                </tr>
@@ -29,7 +29,7 @@
                                <!--#set var='OILS_ADV_CONT_ID' value="advanced.refined.subject_type"-->
                                <!--#include virtual="advanced_contains.xml"-->
                        </td>
                                <!--#set var='OILS_ADV_CONT_ID' value="advanced.refined.subject_type"-->
                                <!--#include virtual="advanced_contains.xml"-->
                        </td>
-                       <td align='center'>
+                       <td colspan='2' align='center'>
                                <input type='text' size='36' id='advanced.refined.subject_contains'> </input>
                        </td>
                </tr>
                                <input type='text' size='36' id='advanced.refined.subject_contains'> </input>
                        </td>
                </tr>
                                <!--#set var='OILS_ADV_CONT_ID' value="advanced.refined.series_type"-->
                                <!--#include virtual="advanced_contains.xml"-->
                        </td>
                                <!--#set var='OILS_ADV_CONT_ID' value="advanced.refined.series_type"-->
                                <!--#include virtual="advanced_contains.xml"-->
                        </td>
-                       <td align='center'>
+                       <td colspan='2' align='center'>
                                <input type='text' size='36' id='advanced.refined.series_contains'> </input>
                        </td>
                </tr>
                <tr>
                        <td><span>&common.format;: </span></td>
                        
                                <input type='text' size='36' id='advanced.refined.series_contains'> </input>
                        </td>
                </tr>
                <tr>
                        <td><span>&common.format;: </span></td>
                        
-                       <td> 
+                       <td colspan='3'
                                <!--#set var='FORM_SEL_ID' value='advanced.refined.form_selector'-->
                                <!--#include virtual="../common/format_selector.xml"--> 
                        </td>
                                <!--#set var='FORM_SEL_ID' value='advanced.refined.form_selector'-->
                                <!--#include virtual="../common/format_selector.xml"--> 
                        </td>
-                       <td colspan='1' align='center'>
+               </tr>
+               <tr>
+                       <td>
+                               <span>Sort results by </span>
+                       </td>
+                       <td>
+                               <select id='advanced.refined.sort_by' 
+                                       onchange='
+                                       if(this.selectedIndex == 0) {
+                                               $("advanced.refined.sort_dir").disabled = true;
+                                               $("advanced.refined.sort_dir").selectedIndex = 0;
+                                       } else $("advanced.refined.sort_dir").disabled = false;'>
+                                       <option value='rel'>Relevance</option>
+                                       <option value='title'>Title</option>
+                                       <option value='author'>Author</option>
+                                       <option value='pubdate' disabled='disabled'>Publication Date</option>
+                               </select>
+                       </td>
+                       <td>
+                               <span>Sort Direction </span>
+                       </td>
+                       <td>
+                               <select id='advanced.refined.sort_dir' disabled='disabled'>
+                                       <option value='asc'>Normal</option>
+                                       <option value='desc'>Reverse</option>
+                               </select>
+                       </td>
+               </tr>
+               <tr>
+                       <td colspan='4' align='center'>
                                <input type='submit' onclick='advRefinedRun();' value='&common.submit;'> </input>
                        </td>
                </tr>
                                <input type='submit' onclick='advRefinedRun();' value='&common.submit;'> </input>
                        </td>
                </tr>
index e23810c..4263081 100644 (file)
@@ -44,6 +44,7 @@
                                        <option value='rel'>Relevance</option>
                                        <option value='title'>Title</option>
                                        <option value='author'>Author</option>
                                        <option value='rel'>Relevance</option>
                                        <option value='title'>Title</option>
                                        <option value='author'>Author</option>
+                                       <option value='pubdate' disabled='disabled'>Publication Date</option>
                                        <!--
                                        <option value='pubdate'>Publication Date</option>
                                        -->
                                        <!--
                                        <option value='pubdate'>Publication Date</option>
                                        -->