basic record level holds working on record result and record detail pages
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 15 Nov 2005 15:20:29 +0000 (15:20 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 15 Nov 2005 15:20:29 +0000 (15:20 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2026 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/skin/default/js/mresult.js
Open-ILS/web/opac/skin/default/js/rdetail.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/mresult.xml
Open-ILS/web/opac/skin/default/xml/myopac_prefs.xml
Open-ILS/web/opac/skin/default/xml/rdetail.xml
Open-ILS/web/opac/skin/default/xml/rresult.xml

index 237054c..585d874 100644 (file)
@@ -224,14 +224,16 @@ function attachEvt(scope, name, action) {
        G.evt[scope][name].push(action);
 }
 
-function detachEvt(scope, name) {
-       G.evt[scope][name] = null;
+function detachAllEvt(scope, name) {
+       G.evt[scope][name] = [];
 }
 
+
 createEvt("common", "init");                                           /* f() : what happens on page init */
 createEvt("common", "pageRendered");                   /* f() : what happens when the page is done (up to the skin to call this even)*/
 createEvt("common", "unload");                                 /* f() : what happens on window unload (clean memory, etc.)*/
 createEvt("common", "locationChanged");                /* f() : what happens when the location has changed */
+createEvt("common", "locationUpdated");                /* f() : what happens when the location has updated by the code */
 
 createEvt("common", "run");                                            /* f() : make the page do stuff */
 createEvt("result", "idsReceived");                            /* f(ids) */
index 629c69e..1e81d04 100644 (file)
@@ -540,6 +540,20 @@ function msg( text ) {
        } catch(e) {}
 }
 
+function findRecord(id,type) {
+       try {
+               for( var i = 0; i != recordsCache.length; i++ ) {
+                       var rec = recordsCache[i];
+                       if( rec && rec.doc_id() == id ) return rec;
+               }
+       } catch(E){}
+       var meth = FETCH_RMODS
+       if(type == 'M') meth = FETCH_MRMODS;
+       var req = new Request(meth, id);
+       req.send(true);
+       return req.result();
+}
+
 
 
 
index 73becea..cdd07f1 100644 (file)
@@ -19,13 +19,10 @@ function mresultDoSearch() {
        while( table.parentNode.rows.length <= (getDisplayCount() + 1) )  /* add an extra row so IE and safari won't complain */
                table.appendChild(G.ui.result.row_template.cloneNode(true));
 
-       if(getOffset() == 0 || getHitCount() == null ) {
-       //      mresultGetCount(); 
+       if(getOffset() == 0 || getHitCount() == null ) 
                mresultCollectIds(FETCH_MRIDS_FULL); 
-       } else { 
-               //runEvt('result', 'hitCountReceived');
+       else  
                mresultCollectIds(FETCH_MRIDS);
-       }
 }
 
 function mresultGetCount() {
index ef98308..207a52d 100644 (file)
@@ -6,6 +6,7 @@ attachEvt("rdetail", "recordDrawn", rdetailBuildInfoRows);
 
 var record = null;
 var cp_statuses = null;
+var recordsCache = [];
 
 var copyRowParent = null;
 var copyRow = null;
@@ -28,6 +29,8 @@ function rdetailDraw() {
        if(getLocation() == globalOrgTree.id())
                hideMe(G.ui.rdetail.cp_info_all);
 
+
+
        var req = new Request(FETCH_RMODS, getRid());
        req.callback(_rdetailDraw);
        req.send();
@@ -90,9 +93,12 @@ function _rdetailDraw(r) {
        G.ui.rdetail.abstr.appendChild(text(record.synopsis()));
 
 
+       $('rdetail_place_hold').setAttribute(
+               'href','javascript:holdsDrawWindow("'+record.doc_id()+'");');
 
        G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
        runEvt("rdetail", "recordDrawn");
+       recordsCache.push(record);
 }
 
 
index 63dfc31..6eee65c 100644 (file)
@@ -8,6 +8,9 @@ G.evt.result.recordReceived.push(resultDisplayRecord, resultAddCopyCounts);
 G.evt.result.copyCountsReceived.push(resultDisplayCopyCounts);
 G.evt.result.allRecordsReceived.push(resultBuildCaches, resultDrawSubjects, resultDrawAuthors, resultDrawSeries);
 
+attachEvt( "common", "locationUpdated", resultSBSubmit );
+function resultSBSubmit(){searchBarSubmit();}
+
 /* do this after we have ID's so the rank for mr pages will be correct */
 attachEvt("result", "preCollectRecords", resultPaginate);
 
@@ -125,7 +128,7 @@ function resultDisplayRecord(rec, pos, is_mr) {
 
                unHideMe($n(r,'place_hold_span'));
                $n(r,'place_hold_link').setAttribute(
-                       'href','javascript:resultDrawHoldsWindow("'+rec.doc_id()+'");');
+                       'href','javascript:holdsDrawWindow("'+rec.doc_id()+'");');
        }
 
        buildSearchLink(STYPE_AUTHOR, rec.author(), author_link);
@@ -172,6 +175,7 @@ function _resultFindRec(id) {
        return null;
 }
 
+/*
 var currentHoldRecord;
 var holdsOrgSelectorBuilt = false;
 function resultDrawHoldsWindow(recid) {
@@ -182,10 +186,16 @@ function resultDrawHoldsWindow(recid) {
        }
        currentHoldRecord = recid;
 
+       detachEvt('common','locationUpdated', resultSBSubmit );
+       attachEvt( "common", "locationUpdated", resultSBSubmit );
+
        if(!(G.user && G.user.session)) {
 
+               detachEvt('common','locationUpdated', resultSBSubmit );
                attachEvt('common','loggedIn', resultDrawHoldsWindow)
+               //alert(G.evt['common']['locationUpdated']);
                initLogin();
+               //attachEvt( "common", "locationUpdated", resultSBSubmit );
                return;
        }
        swapCanvas($('holds_box'));
@@ -244,8 +254,9 @@ function resultBuildHoldsSelector(node, depth) {
        
        } else {
                var pad = (findOrgType(node.ou_type()).depth() - 1) * 12;
+               if(pad < 0) pad = 0;
                var select = new Option(node.name(), node.id());
-               select.setAttribute("style", "padding-left: " + pad);
+               select.setAttribute("style", "padding-left: "+pad+'px;');
                selector.options[index] = select;
        }       
 
@@ -263,10 +274,8 @@ function resultBuildHoldsSelector(node, depth) {
 }
 
 function resultPlaceHold() {
-       //alert("placing hold for " + currentHoldRecord );
-
        var hold = new ahr();
-       hold.pickup_lib( 1 ); /* */
+       hold.pickup_lib( 1 ); 
        hold.requestor(G.user.id());
        hold.usr(G.user.id());
        hold.hold_type('T');
@@ -278,13 +287,13 @@ function resultPlaceHold() {
        req.send(true);
        var res = req.result();
 
-       /* XMLize me */
        if( res == '1' ) {
                alert('ok');
        } else {
                alert('hold failed');
        }
 }
+*/
 
 
 
@@ -302,17 +311,10 @@ function resultBuildFormatIcons( row, rec ) {
 
                var f = getForm();
                if( f != "all" ) {
-                       /*
-                       if( f != modsFormatToMARC(res) ) 
-                               addCSSClass( img, config.css.dim2);
-                       else
-                               addCSSClass( img, "dim2_border");
-                               */
                        if( f == modsFormatToMARC(res) ) 
                                addCSSClass( img, "dim2_border");
                }
 
-
                var args = {};
                args.page = RRESULT;
                args[PARAM_OFFSET] = 0;
@@ -322,7 +324,6 @@ function resultBuildFormatIcons( row, rec ) {
                link.setAttribute("href", buildOPACLink(args));
 
        }
-
 }
 
 
index 6533496..d472f40 100644 (file)
@@ -56,7 +56,6 @@ function _opacHandleLocationTagClick() {
        if(!orgTreeIsBuilt) {
                drawOrgTree();
                orgTreeIsBuilt = true;
-               //hideMe($('org_loading_div'));
        }
 
 }
@@ -129,10 +128,14 @@ function updateLoc(location, depth) {
                newSearchDepth = depth;
        }
 
+       runEvt('common','locationUpdated');
+
+       /*
        if(!isFrontPage && (findCurrentPage() != MYOPAC) 
                                && (newSearchLocation != getLocation()) ) {
                searchBarSubmit();
        }
+       */
 }
 
 
index b22a99a..ae2b1e2 100644 (file)
@@ -9,6 +9,7 @@
                <script language='javascript' src='../js/mresult.js'> </script>
                <script language='javascript' src='../js/result_common.js'> </script>
                <script language='javascript' src='../js/tips.js'> </script>
+               <script language='javascript' src='../js/holds.js'> </script>
        </head>
 
        <body onload="init();">
index d24fea3..98090b9 100644 (file)
@@ -13,7 +13,9 @@
                </thead>
 
                <tbody id='myopac_prefs_tbody'>
+                       <!--
                        <tr id='myopac_prefs_loading'><td>Loading...</td></tr>
+                       -->
                        <tr id='myopac_prefs_row' class='light_border hide_me'>
                        </tr>
                </tbody>
index 43ffdd8..9564c82 100644 (file)
@@ -8,6 +8,7 @@
                <xi:include href="css_common.xml"/>
                <xi:include href="js_common.xml"/>
                <script language='javascript' src='../js/rdetail.js'> </script>
+               <script language='javascript' src='../js/holds.js'> </script>
        </head>
 
        <script language='javascript'>
@@ -39,6 +40,9 @@
                                                                                                <span>&rdetail.detailMain.headerLabel;</span>
                                                                                        </td>
                                                                                        <td align='right' style='padding-right: 7px;'>
+                                                                                               <span style='padding-right: 15px;'>
+                                                                                                       <a id='rdetail_place_hold'>Place Hold</a>
+                                                                                               </span>
                                                                                                <a href="javascript:void(0);" id='rdetail_view_marc'>&rdetail.detailMain.viewMarc;</a>
                                                                                        </td>
                                                                                </tr>
index 5ef37ec..4650ae3 100644 (file)
@@ -10,6 +10,7 @@
                <script language='javascript' src='../js/rresult.js'> </script>
                <script language='javascript' src='../js/result_common.js'> </script>
                <script language='javascript' src='../js/tips.js'> </script>
+               <script language='javascript' src='../js/holds.js'> </script>
        </head>
 
        <body onload="init();">