more advanced search fun
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 15 Dec 2005 23:10:45 +0000 (23:10 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 15 Dec 2005 23:10:45 +0000 (23:10 +0000)
marc search added and tested
breaking up opac into smaller manageable chunks

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

13 files changed:
Open-ILS/src/extras/fieldmapper.pl
Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/common/js/opac_utils.js
Open-ILS/web/opac/skin/default/js/mresult.js
Open-ILS/web/opac/skin/default/js/result_common.js
Open-ILS/web/opac/skin/default/js/search_bar.js
Open-ILS/web/opac/skin/default/xml/advanced/advanced_location.xml
Open-ILS/web/opac/skin/default/xml/advanced/advanced_marc.xml
Open-ILS/web/opac/skin/default/xml/advanced/advanced_quick.xml
Open-ILS/web/opac/skin/default/xml/common/libselect.xml
Open-ILS/web/opac/skin/default/xml/common/searchbar.xml
Open-ILS/web/opac/skin/default/xml/home/homesearch.xml

index 23c719e..50589a5 100755 (executable)
@@ -12,7 +12,7 @@ if(!$web) { $web = ""; }
 # List of classes needed by the opac
 my @web_hints = qw/asv asva asvr asvq 
                circ acp acpl acn ccs ahn  
-               crcd crmf crrf mbts aoc aus mous/;
+               crcd crmf crrf mbts aoc aus mous mobts/;
 
 my @web_core = qw/ aou au perm_ex ex aout mvr ccs ahr aua ac actscecm /;
 
index 539930a..7cdb2b7 100644 (file)
@@ -633,7 +633,7 @@ sub biblio_search_class {
        if( !defined($org_id) or !$class or !$string ) {
                warn "not enbough args to metarecord search\n";
                throw OpenSRF::EX::InvalidArg 
-                       ("Not enough args to open-ils.search.cat.biblio.class")
+                       ("Not enough args to open-ils.search.biblio.class")
        }
 
        $class =~ s/\s+//g;
index 60b6496..994182d 100644 (file)
@@ -15,6 +15,7 @@ var PARAM_ORIGLOC             = "ol";                 /* the original location */
 var PARAM_TOPRANK              = "tr";                 /* this highest ranking rank */
 var PARAM_AUTHTIME     = "at";                 /* inactivity timeout in seconds */
 var PARAM_ADVTERM              = "adv";                        /* advanced search term */
+var PARAM_ADVTYPE              = "adt";                        /* the advanced search type */
 
 /* URL param values (see comments above) */
 var TERM;  
@@ -31,6 +32,7 @@ var ORIGLOC;
 var TOPRANK;
 var AUTHTIME;
 var ADVTERM;
+var ADVTYPE;
 
 /* cookie values */
 var SBEXTRAS; 
@@ -56,11 +58,15 @@ var HOME                    = "home";
 
 /* search type (STYPE) options */
 var STYPE_AUTHOR       = "author";
-var STYPE_TITLE                = "title";
+var STYPE_TITLE        = "title";
 var STYPE_SUBJECT      = "subject";
 var STYPE_SERIES       = "series";
 var STYPE_KEYWORD      = "keyword";
 
+/* types of advanced search */
+var ADVTYPE_MULTI = 'ml';
+var ADVTYPE_MARC = 'ma'
+
 var LOGOUT_WARNING_TIME = 30; /* "head up" for session timeout */
 
 
@@ -213,10 +219,10 @@ var FETCH_TOC                                             = "open-ils.search:open-ils.search.added_content.toc.retrieve
 var FETCH_ACONT_SUMMARY                        = "open-ils.search:open-ils.search.added_content.summary.retrieve";
 var FETCH_USER_BYBARCODE               = "open-ils.actor:open-ils.actor.user.fleshed.retrieve_by_barcode";
 var FETCH_ADV_MRIDS                            = "open-ils.search:open-ils.search.biblio.multiclass:1";
+var FETCH_ADV_MARC_MRIDS               = "open-ils.search:open-ils.search.biblio.marc:1";
 /* ---------------------------------------------------------------------------- */
 
 
-
 /* ---------------------------------------------------------------------------- */
 /* event callback functions. Other functions may be appended to these vars to
        for added functionality.  */
@@ -270,6 +276,7 @@ createEvt("common", "loggedIn");                                    /* f() : user has just logged in */
 createEvt('result', 'zeroHits');
 createEvt('result', 'lowHits');
 createEvt('rdetail', 'recordRetrieved');                       /* we are about to draw the rdetail page */
+createEvt('common', 'depthChanged');
 
 
 
index 030fe00..f1b0a2b 100644 (file)
@@ -21,7 +21,7 @@ function showCanvas() {
        }
        hideMe(G.ui.common.loading);
        unHideMe(G.ui.common.canvas_main);
-       G.ui.searchbar.text.focus(); 
+       try{G.ui.searchbar.text.focus();}catch(e){}
 }
 
 function swapCanvas(newNode) {
@@ -81,6 +81,7 @@ function initParams() {
        TOPRANK  = parseFloat(cgi.param(PARAM_TOPRANK));
        AUTHTIME        = parseInt(cgi.param(PARAM_AUTHTIME));
        ADVTERM = cgi.param(PARAM_ADVTERM);
+       ADVTYPE = cgi.param(PARAM_ADVTYPE);
 
        /* set up some sane defaults */
        if(isNaN(LOCATION))     LOCATION        = 1;
@@ -117,11 +118,11 @@ function getRid(){return RID;};
 function getOrigLocation(){return ORIGLOC;}
 function getTopRank(){return TOPRANK;}
 function getAuthtime() { return AUTHTIME; }
-
 function getSearchBarExtras(){return SBEXTRAS;}
 function getFontSize(){return FONTSIZE;};
 function getSkin(){return SKIN;};
 function getAdvTerm(){return ADVTERM;}
+function getAdvType(){return ADVTYPE;}
 
 
 function findBasePath() {
@@ -180,6 +181,7 @@ function  buildOPACLink(args, slim, ssl) {
        string += _appendParam(TOPRANK, PARAM_TOPRANK, args, getTopRank, string);
        string += _appendParam(AUTHTIME,        PARAM_AUTHTIME, args, getAuthtime, string);
        string += _appendParam(ADVTERM, PARAM_ADVTERM, args, getAdvTerm, string);
+       string += _appendParam(ADVTYPE, PARAM_ADVTYPE, args, getAdvType, string);
 
        return string.replace(/\&$/,'').replace(/\?\&/,"?");    
 }
@@ -282,8 +284,8 @@ function grabUser(ses, force) {
 
        var at = getAuthtime();
        if(isXUL()) at = xulG['authtime'];
-       //alert(at);
-       new AuthTimer(at).run();
+
+       //new AuthTimer(at).run(); /* needs debugging... */
 
        return G.user;
 }
index 29a4629..52bebf9 100644 (file)
@@ -31,11 +31,17 @@ function mresultDoSearch() {
                table.appendChild(G.ui.result.row_template.cloneNode(true));
 
        if(getOffset() == 0 || getHitCount() == null ) {
-               if( getAdvTerm() && !getTerm() ) mresultCollectAdvIds(1);
+               if( getAdvTerm() && !getTerm() ) {
+                       if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();
+                       if(getAdvType() == ADVTYPE_MARC ) mresultCollectAdvMARCIds();
+               }
                else mresultCollectIds(FETCH_MRIDS_FULL); 
 
        } else  {
-               if( getAdvTerm() && !getTerm()) mresultCollectAdvIds();
+               if( getAdvTerm() && !getTerm() ) {
+                       if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();
+                       if(getAdvType() == ADVTYPE_MARC ) mresultCollectAdvIds();
+               }
                else mresultCollectIds(FETCH_MRIDS);
        }
 }
@@ -57,24 +63,29 @@ function mresultHandleCount(r) {
 */
 
 
-/* performs the actual search */
-function mresultCollectIds(method) {
-
+function mresultLoadCachedSearch() {
        if( (getOffset() > 0) && (getOffset() < mresultPreCache) ) {
-               //alert('cached: ' + idsCookie.read(COOKIE_IDS));
                var c = JSON2js(idsCookie.read(COOKIE_IDS));
                if(c) { records = c[0]; ranks = c[1]; }
        }
+}
 
-       if(     getOffset() != 0 && 
-                       records[getOffset()] != null && 
+function mresultTryCachedSearch() {
+       mresultLoadCachedSearch();
+       if(     getOffset() != 0 && records[getOffset()] != null && 
                        records[resultFinalPageIndex()] != null) {
-                       //alert('we have cookies...  offset : ' + getOffset() );
-                       runEvt('result', 'hitCountReceived');
-                       mresultCollectRecords(); 
 
-       } else {
+               runEvt('result', 'hitCountReceived');
+               mresultCollectRecords(); 
+               return true;
+       }
+       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 );
@@ -85,20 +96,7 @@ function mresultCollectIds(method) {
 
 
 function mresultCollectAdvIds() {
-
-       if( (getOffset() > 0) && (getOffset() < mresultPreCache) ) {
-               var c = JSON2js(idsCookie.read(COOKIE_IDS));
-               if(c) { records = c[0]; ranks = c[1]; }
-       }
-
-       if(     getOffset() != 0 && 
-                       records[getOffset()] != null && 
-                       records[resultFinalPageIndex()] != null) {
-                       runEvt('result', 'hitCountReceived');
-                       mresultCollectRecords(); 
-
-       } else {
-
+       if(!mresultTryCachedSearch()) {
                var form = (getForm() == "all") ? null : getForm();
                var req = new Request(FETCH_ADV_MRIDS, 
                        JSON2js(getAdvTerm()), getLocation(), form, mresultPreCache );
@@ -107,6 +105,16 @@ function mresultCollectAdvIds() {
        }
 }
 
+function mresultCollectAdvMARCIds() {
+       if(!mresultTryCachedSearch()) {
+               var form = (getForm() == "all") ? null : getForm();
+               var req = new Request(FETCH_ADV_MARC_MRIDS, 
+                       JSON2js(getAdvTerm()), getLocation(), form );
+               req.callback(mresultHandleMRIds);
+               req.send();
+       }
+}
+
 
 
 function mresultHandleMRIds(r) {
index b9ceb2e..0560621 100644 (file)
@@ -29,8 +29,11 @@ function resultFinalPageIndex() {
 /* set the search result info, number of hits, which results we're 
        displaying, links to the next/prev pages, etc. */
 function resultSetHitInfo() { 
+
+       try{searchTimer.stop()}catch(e){}
+
        if( findCurrentPage() == MRESULT ) {
-               if(getHitCount() <= lowHitCount)
+               if(getHitCount() <= lowHitCount && getTerm())
                        runEvt('result', 'lowHits');
                if(getHitCount() == 0) {
                        runEvt('result', 'zeroHits');
@@ -55,7 +58,6 @@ function resultSetHitInfo() {
 }
 
 function resultLowHits() {
-       try{searchTimer.stop()}catch(e){}
        showCanvas();
        unHideMe($('result_low_hits'));
        if(getHitCount() > 0)
@@ -111,8 +113,10 @@ function resultLowHitXRef(r) {
 }
 
 function resultZeroHits() {
+       showCanvas();
+       unHideMe($('result_low_hits'));
        unHideMe($('result_zero_hits_msg'));
-       resultExpandSearch();
+       if(getTerm()) resultExpandSearch(); /* advanced search */
 }
 
 function resultExpandSearch() {
index 0aa23d0..02cba3f 100644 (file)
@@ -1,8 +1,7 @@
 var searchBarExpanded = false;
 /* our search selector boxes */
-var _ts, _fs, _ds;
+var _ts, _fs;
 
-attachEvt( "common", "locationChanged", updateLoc );
 
 var isFrontPage = false;
 
@@ -14,136 +13,42 @@ G.evt.common.init.push(searchBarInit);
 var newSearchLocation; 
 var newSearchDepth = null;
 
+
 function searchBarInit() {
 
        _ts = G.ui.searchbar.type_selector;
-       _ds = G.ui.searchbar.depth_selector;
        _fs = G.ui.searchbar.form_selector;
 
        G.ui.searchbar.text.focus();
-       //G.ui.searchbar.text.onkeypress = 
        G.ui.searchbar.text.onkeydown = 
                function(evt) {if(userPressedEnter(evt)) { searchBarSubmit(); } };
 
        G.ui.searchbar.submit.onclick = searchBarSubmit;
 
-       _ds.onchange = depthSelectorChanged;
-
-       if( getLocation() == globalOrgTree.id() ) {
-               unHideMe( G.ui.searchbar.lib_sel_span );
-               G.ui.searchbar.lib_sel_link.onclick = _opacHandleLocationTagClick;
-       } else {
-               unHideMe( G.ui.searchbar.depth_sel_span );
-               buildLocationSelector();
-       }
-
        /* set up the selector objects, etc */
        G.ui.searchbar.text.value = (getTerm() != null) ? getTerm() : "";
        setSelector(_ts,        getStype());
-       setSelector(_ds,        getDepth());
        setSelector(_fs,        getForm());
 
-}
+       depthSelInit();
 
-var orgTreeIsBuilt = false;
-function _opacHandleLocationTagClick() {
-       /*
-       orgTreeSelector.openTo(  
-               (newSearchLocation != null) ? parseInt(newSearchLocation) : getLocation(), true );
-               */
-       swapCanvas(G.ui.common.org_container);
-
-       if(!orgTreeIsBuilt) {
-               drawOrgTree();
-               orgTreeIsBuilt = true;
-       }
 
-}
-
-function depthSelectorChanged() {
-       var i = _ds.selectedIndex;
-       if( i == _ds.options.length - 1 ) {
-               setSelector( _ds, getDepth() );
-               _opacHandleLocationTagClick();
-
-       } else {
-               if(!isFrontPage && (findCurrentPage() != MYOPAC)) {
-                       searchBarSubmit();
-               }
+       if(!isFrontPage && (findCurrentPage() != MYOPAC)) {
+               attachEvt('common','depthChanged', searchBarSubmit);
        }
 
 }
 
-var chooseAnotherNode;
-function buildLocationSelector(newLoc) {
-
-       var loc;
-       if(newLoc != null) loc = newLoc;
-       else loc = getLocation();
-
-       if( loc == globalOrgTree.id() ) return;
-
-       var selector = G.ui.searchbar.depth_selector
-       if(!chooseAnotherNode) 
-               chooseAnotherNode = selector.removeChild(
-                       selector.getElementsByTagName("option")[0]);
-       var node = chooseAnotherNode;
-       removeChildren(selector);
-       
-       var location = findOrgUnit(loc);
-       var type = findOrgType(location.ou_type());
-
-       while( type && location ) {
-               var n = node.cloneNode(true);   
-               n.setAttribute("value", type.depth());
-               removeChildren(n);
-               n.appendChild(text(type.opac_label()));
-               selector.appendChild(n);
-               location = findOrgUnit(location.parent_ou());
-               if(location) type = findOrgType(location.ou_type());
-               else type = null;
-       }
-
-       selector.appendChild(node);
-}
-
-function updateLoc(location, depth) {
-       if( location != null )
-               newSearchLocation = location;
-
-       if( depth != null ) {
-               if(depth != 0 ){
-                       G.ui.searchbar.lib_sel_link.onclick = _opacHandleLocationTagClick;
-                       if( location == globalOrgTree.id() ) {
-                               hideMe( G.ui.searchbar.depth_sel_span );
-                               unHideMe( G.ui.searchbar.lib_sel_span );
-                       } else {
-                               buildLocationSelector(location);
-                               hideMe( G.ui.searchbar.lib_sel_span );
-                               unHideMe( G.ui.searchbar.depth_sel_span );
-                       }
-               }
-
-               setSelector(G.ui.searchbar.depth_selector, depth);
-               newSearchDepth = depth;
-       }
+function searchBarSubmit() {
 
-       runEvt('common','locationUpdated');
+       var text = G.ui.searchbar.text.value;
 
-       /*
-       if(!isFrontPage && (findCurrentPage() != MYOPAC) 
-                               && (newSearchLocation != getLocation()) ) {
-               searchBarSubmit();
+       if(!text) { /* assume it's an advaned search? */
+               if(getAdvTerm()){}
        }
-       */
-}
-
 
-function searchBarSubmit() {
-
-       var text = G.ui.searchbar.text.value;
        if(!text || text == "") return;
-       var d   = (newSearchDepth != null) ? newSearchDepth : parseInt(_ds.options[_ds.selectedIndex].value);
+       var d   = (newSearchDepth != null) ?  newSearchDepth : depthSelGetDepth();
        if(isNaN(d)) d = 0;
 
        var args = {};
@@ -151,7 +56,7 @@ function searchBarSubmit() {
        args[PARAM_OFFSET]      = 0;
        args[PARAM_TERM]                = text;
        args[PARAM_STYPE]               = _ts.options[_ts.selectedIndex].value;
-       args[PARAM_LOCATION] = newSearchLocation;
+       args[PARAM_LOCATION] = depthSelGetNewLoc();
        args[PARAM_DEPTH]               = d;
        args[PARAM_FORM]                = _fs.options[_fs.selectedIndex].value;
 
index 6cda6a2..70fc9d7 100644 (file)
@@ -1,9 +1,9 @@
 <table>
        <tbody>
                <tr>
+                       <!--#set var="SHOW_DEPTHSEL_TEXT" value="true"-->
                        <td><!--#include virtual="../common/statusbar.xml"--></td>
-                       <td><a style='padding-left: 20px;'  href='javascript:void(0);'
-                               class='classic_link'>Change search location</a></td>
+                       <td style='padding-left: 20px;'><!--#include virtual="../common/libselect.xml"--></td>
                </tr>
        </tbody>
 </table>
index 88a3833..7792b43 100644 (file)
                        </td>
 
                        <td>
-                               <input name='advanced.marc.addrow' type='submit'
+                               <input name='advanced.marc.addrow' type='submit' onclick='advAddMARC();'
                                        value='&opac.advanced.marc.addrow;'> </input>
                        </td>
                </tr>
-               <tr>
+               <tr id='advanced.marc.submit.row'>
                        <td colspan='6'>
-                               <input name='advanced.marc.submit' 
-                                       type='submit' value='&common.submit;'> </input>
+                               <input onclick='advMARCRun();' type='submit' value='&common.submit;'> </input>
                        </td>
                </tr>
        </tbody>
index 3ee3471..471cb2f 100644 (file)
@@ -9,12 +9,12 @@
                        <td>
                                <span style='padding-right: 10px;'>&opac.advanced.quick.isbn;:</span>
                                <input style='margin: 5px;' type='text' size='10' maxlength='10'> </input>
-                               <input type='submit' id='opac.advanced.quick.isbn.submit' value='&common.submit;'> </input>
+                               <input type='submit' onclick='alert("not yet");' id='opac.advanced.quick.isbn.submit' value='&common.submit;'> </input>
                        </td>
                        <td>
                                <span style='padding-right: 10px;'>&opac.advanced.quick.issn;:</span>
                                <input style='margin: 5px;' type='text' size='8' maxlength='8'> </input>
-                               <input type='submit' id='opac.advanced.quick.issn.submit' value='&common.submit;'> </input>
+                               <input type='submit' onclick='alert("not yet");' id='opac.advanced.quick.issn.submit' value='&common.submit;'> </input>
                        </td>
                </tr>
        </tbody>
index 7645516..95291f0 100644 (file)
@@ -1,5 +1,9 @@
 <span>
+       <script language='javascript' src='../js/depth_selector.js'> </script>
        <span class='hide_me' id='depth_selector_span'>
+               <!--#if expr="$SHOW_DEPTHSEL_TEXT='true'"-->
+               <span>Find results in </span>
+               <!--#endif-->
                <select id='depth_selector' >
                        <option value='new'>Choose a different library...</option>
                </select>
index 65f49ef..965e33e 100644 (file)
@@ -4,8 +4,6 @@
 <div id='searchbar'>
 
        <!-- load my js -->
-       <script language='javascript' src='../js/search_bar.js'> </script>
-
        <script language='javascript'>
                config.ids.searchbar = {};
                config.css.searchbar = {};
@@ -56,6 +54,7 @@
                        </tr>
                </tbody>
        </table>
+       <script language='javascript' src='../js/search_bar.js'> </script>
 </div>
 
 
index 421432c..a1151c6 100644 (file)
@@ -4,6 +4,7 @@
        xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude">
 
        <!-- load my js -->
+       <script language='javascript' src='../js/depth_selector.js'> </script>
        <script language='javascript' src='../js/search_bar.js'> </script>
 
        <script language='javascript'>
@@ -70,6 +71,7 @@
 
                                        <span style='padding-right:9px;'>
                                                <span>&common.format;: </span>
+                                               <!--#set var='FORM_SEL_ID' value='form_selector'-->
                                                <!--#include virtual="../common/format_selector.xml"-->
                                        </span>