Let the web grow!
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 1 Jul 2005 19:51:33 +0000 (19:51 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 1 Jul 2005 19:51:33 +0000 (19:51 +0000)
added a lot of holds processing for creating holds and viewing holds

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

12 files changed:
Evergreen/css/opac/my_opac.css
Evergreen/css/opac/opac_main.css
Open-ILS/src/javascript/opac/AbstractRecordResultPage.js
Open-ILS/src/javascript/opac/HoldsWindow.js
Open-ILS/src/javascript/opac/Page.js
Open-ILS/src/javascript/opac/RecordDetailPage.js
Open-ILS/src/javascript/util/RemoteRequest.js
Open-ILS/src/javascript/util/UserSession.js
Open-ILS/src/javascript/util/ils_utils.js
Open-ILS/src/javascript/util/webutils.js
Open-ILS/src/templates/opac/pages/my_opac_secure.ttk
Open-ILS/src/templates/opac/pages/record_detail.ttk

index d5515bb..1caeb1a 100644 (file)
@@ -67,6 +67,6 @@
 }
 
 .my_opac_update_table td {
-       padding-left: 8px;
+       padding-left: 12px;
 }
 
index 7f36fe3..7849ff9 100644 (file)
@@ -183,4 +183,13 @@ table { border-collapse: collapse; }
        text-align:center;
 }
 
+.login_dialog {
+       position: absolute;
+       z-index: 40;
+       top: 10px;
+       border: 2px solid lightblue;
+       background: #FFE;
+       padding: 10px;
+}
+
 
index 20f40c1..e9fe26a 100644 (file)
@@ -45,7 +45,6 @@ AbstractRecordResultPage.prototype.init = function() {
        this.theadDrawn         = false;
        this.bigOlBox                   = getById("big_ol_box");
 
-
 }
 
 
@@ -201,6 +200,7 @@ AbstractRecordResultPage.prototype.displayRecord =
 
 
        var c = misc_row.insertCell(0);
+
        /* shove in a div for each of the types of resource */
        for( var i = 0; i!= 9; i++) {
                var div = createAppElement("div");
@@ -275,6 +275,7 @@ AbstractRecordResultPage.prototype.displayRecord =
        author_cell.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        author_cell.appendChild(this.mkLink(record.doc_id(), "author", author ));
 
+       var marcd = elem("div");
        if(instanceOf(this, RecordResultPage)) {
                var span = createAppElement("span");
                span.style.marginLeft = "10px";
@@ -300,11 +301,12 @@ AbstractRecordResultPage.prototype.displayRecord =
                var func = buildViewMARCWindow(record);
                marcb.onclick = func;
 
-               var marcd = elem( "div", { style: "float:right" } );
+               marcd = elem( "div", { style: "float:right" } );
                marcd.appendChild(marcb);
+
                //author_cell.appendChild(marcd);
                //misc_row.insertCell(misc_row.cells.length).appendChild(marcd);
-               c.appendChild(marcd);
+               //c.appendChild(marcd);
 
 
        }
@@ -315,22 +317,23 @@ AbstractRecordResultPage.prototype.displayRecord =
                style: "text-decoration:underline" 
        }, {}, "Place Hold" );
 
-       var user = UserSession.instance();
 
-       /*
-       if(!(user && user.verifySession()))  
-               return;
-               */
-       
        var type = "M";
        if(instanceOf(this, RecordResultPage))
                type = "T";
 
-       var win = new HoldsWindow(record.doc_id(), 
+       var win;
+       var user = UserSession.instance();
+       if(user.verifySession()) {
+               win = new HoldsWindow(record.doc_id(), 
                        type, user.userObject, user.userObject, user.session_id);
+       } else {
+               win = new HoldsWindow(record.doc_id(), 
+                       type, null, null, null);
+       }
 
-       win.buildWindow(); 
-       holds.onclick = function() { win.toggle(); }
+       
+       holds.onclick = function() { win.toggle(holds); }
        var holddiv = elem("div");
 
        //if(instanceOf(this,RecordResultPage))
@@ -339,9 +342,21 @@ AbstractRecordResultPage.prototype.displayRecord =
        holddiv.appendChild(holds);
        //var space = elem("span", {style:"padding:5px"},null, " ");
        //c.appendChild(space)
-       c.appendChild(mktext(" "))
-       c.appendChild(holddiv)
+       //c.appendChild(mktext(" "))
+       //c.appendChild(holddiv)
+
+       var tab = elem("table",{style:"float:right"});
+       var tr = tab.insertRow(0);
+       var tc = tr.insertCell(0);
+       var tc2 = tr.insertCell(1);
+       var tc3 = tr.insertCell(2);
+       tc.setAttribute("nowrap", "nowrap");
+       tc3.setAttribute("nowrap", "nowrap");
 
+       tc.appendChild(marcd);
+       tc2.appendChild(mktext(" "));
+       tc3.appendChild(holddiv);
+       c.appendChild(tab);
 
 
 
@@ -635,6 +650,9 @@ function buildResourcePic(c, resource) {
 
        var pic = createAppElement("img");
 
+
+       if(resource.indexOf("sound recording") != -1) 
+               resource = "sound recording";
        pic.setAttribute("src", "/images/" + resource + ".jpg");
        pic.className = "record_resource_pic";
        pic.setAttribute("width", "20");
index e7082db..a2fe044 100644 (file)
@@ -1,14 +1,3 @@
-var resourceFormats = [ 
-       "text", 
-       "moving image",
-       "sound recording",
-       "software, multimedia",
-       "still images",
-       "cartographic",
-       "mixed material",
-       "notated music",
-       "three dimensional object" ];
-
 
 /* 
        @param record the id of the target item 
@@ -27,6 +16,7 @@ function HoldsWindow(record, type, requestor, recipient, requestor_login) {
        this.recipient  = recipient;
        this.type = type;
        this.session = requestor_login;
+       this.built = false;
 
        add_css_class(this.div, "holds_window");
        add_css_class(this.div, "hide_me");
@@ -89,13 +79,27 @@ HoldsWindow.prototype.sendHoldsRequest = function(formats, org, email, phone) {
 
 }
 
-HoldsWindow.prototype.buildWindow = function() {
+/* returns false if we don't have a recipient for the hold */
+HoldsWindow.prototype.buildWindow = function(node) {
 
+       if(this.built) return true;
        var d = elem("div");
        var id = this.record;
 
        var usr = this.recipient;
-       if(!usr) return;
+       if(!usr) {
+               var obj = this;
+               var func = function(usr) { 
+                       obj.recipient = usr.userObject;
+                       obj.requestor = usr.userObject;
+                       obj.session = usr.session_id;
+                       obj.toggle();
+               }
+               var diag = new LoginDialog(getDocument().body, func);
+               diag.display(node);
+               return false;
+       }
+
        var org = usr.home_ou();
        d.appendChild(this.buildPickuplibSelector(org));
 
@@ -104,9 +108,16 @@ HoldsWindow.prototype.buildWindow = function() {
        d.appendChild(this.buildSubmit());
 
        this.div.appendChild(d);
+       this.built = true;
+       return true;
 }
 
-HoldsWindow.prototype.toggle = function() {
+HoldsWindow.prototype.toggle = function(node) {
+
+       debug("Building window with node " + node);
+       if(!this.built) 
+               if(!this.buildWindow(node)) return;
+
        swapClass( this.div, "hide_me", "show_me" );
 
 
@@ -114,7 +125,7 @@ HoldsWindow.prototype.toggle = function() {
        if(IE) {
 
                var sels = getDocument().getElementsByTagName("select");
-               if(sels.length == 0) return;
+               if(sels.length == 0) return true;
 
                if(this.div.className.indexOf("hide_me") != -1)  {
                        for(var i = 0; i!= sels.length; i++) {
@@ -136,6 +147,8 @@ HoldsWindow.prototype.toggle = function() {
                        }
                }
        }
+
+       return true;
 }
 
 /*
@@ -185,18 +198,18 @@ HoldsWindow.prototype.buildSubmit = function() {
        add_css_class(bdiv, "holds_window_buttons");
 
        var button = elem("input", 
-               {type:"submit", style:"margin-left: 10px;", value:"Place Hold"});
+               {type:"submit", style:"margin-right: 10px;", value:"Place Hold"});
 
        var cancel = elem("input", 
-               {type:"submit", style:"margin-right: 10px;",value:"Cancel"});
+               {type:"submit", style:"margin-left: 10px;",value:"Cancel"});
        var obj = this;
 
        cancel.onclick = function() { obj.toggle(); }
        button.onclick = function() { obj.toggle(); obj.process(); }
 
        div.appendChild(elem("br"));
-       bdiv.appendChild(cancel);
        bdiv.appendChild(button);
+       bdiv.appendChild(cancel);
        div.appendChild(bdiv);
 
        return div;
@@ -319,13 +332,6 @@ HoldsWindow.prototype.buildResourceSelector = function() {
 
 }
 
-function mkResourceImage(resource) {
-       var pic = elem("img");
-       pic.setAttribute("src", "/images/" + resource + ".jpg");
-       pic.setAttribute("width", "20");
-       pic.setAttribute("height", "20");
-       pic.setAttribute("title", resource);
-       return pic;
-}
+
 
 
index 41b45b6..d76b4a7 100644 (file)
@@ -233,8 +233,10 @@ Page.prototype.buildNavBox = function(full) {
        Page.navBox.finalize();
 
        var location = getById("main_page_nav_box");
-       if(location) 
+       if(location) {
+               removeChildren(location);
                location.appendChild(Page.navBox.getNode());
+       }
        
 
        return Page.navBox.getNode();
index 7138b22..e408753 100644 (file)
@@ -76,6 +76,8 @@ RecordDetailPage.prototype.draw = function() {
                tree.selectedIndex = idx;
                var opt = tree.options[idx];
                if(opt) opt.selected = true;    
+
+               obj.displayParentLink(findOrgUnit(org_id), obj.record);
                
        }
 
@@ -133,7 +135,7 @@ RecordDetailPage.prototype.buildCustomOrgTree = function(record) {
 /* builds the select list with the appropriate org units */
 function _fleshOrgTree(org_array, selector) {
 
-       debug("Fleshing org tree selector");
+       debug("Fleshing org tree selector with " + org_array);
 
        for( var idx in org_array ) {
                var slot = org_array[idx];
@@ -141,9 +143,20 @@ function _fleshOrgTree(org_array, selector) {
                _addOrgAndParents(selector, org);
        }
 
+       /* clear out the state flags we added after the tree is built */
+       setTimeout(function(){_clearOrgFlags();}, 500);
+
        debug("Tree is built..");
 }
 
+function _clearOrgFlags(node) {
+       if(node == null)
+               node = globalOrgTree;
+       node.added = false;
+       for(var c in node.children()) 
+               _clearOrgFlags(node.children()[c]);
+}
+
 
 function _addOrgAndParents(selector, org) {
 
@@ -239,13 +252,15 @@ RecordDetailPage.prototype.setPlaceHold = function(record) {
                {}, "Place Hold" );
 
        var user = UserSession.instance();
-       if(!(user && user.verifySession()))  /* needs to pop up a login dialog XXX */
-               return;
-
-       var win = new HoldsWindow(record.doc_id(), 
+       var win;
+       if(user.verifySession()) {
+               win = new HoldsWindow(record.doc_id(), 
                        "T", user.userObject, user.userObject, user.session_id);
-       win.buildWindow(); 
-       holds.onclick = function() { win.toggle(); }
+       } else {
+               win = new HoldsWindow(record.doc_id(), 
+                       "T", null, null, null);
+       }
+       holds.onclick = function() { win.toggle(holds); }
 
        var space = elem("span", {style:"padding:5px"},null, " ");
        this.viewMarc.appendChild(space);
@@ -294,6 +309,7 @@ RecordDetailPage.prototype.drawRecord = function(record) {
        var tcn_cell                    = getById("record_detail_tcn_cell");
        var resource_cell               = getById("record_detail_resource_cell");
        var pic_cell                    = getById("record_detail_pic_cell");
+       var abstract_cell               = getById("record_detail_abstract_cell");
 
        add_css_class(title_cell,               "detail_item_cell");
        add_css_class(author_cell,              "detail_item_cell");
@@ -304,6 +320,7 @@ RecordDetailPage.prototype.drawRecord = function(record) {
        add_css_class(subject_cell,     "detail_item_cell");
        add_css_class(tcn_cell,                 "detail_item_cell");
        add_css_class(resource_cell,    "detail_item_cell");
+       add_css_class(abstract_cell,    "detail_item_cell");
 
        title_cell.appendChild(
                createAppTextNode(normalize(record.title())));
@@ -324,10 +341,15 @@ RecordDetailPage.prototype.drawRecord = function(record) {
        tcn_cell.appendChild(
                createAppTextNode(record.tcn()));
 
+       var abs = record.synopsis();
+       if(abs == null || abs == "") abs = "N/A";
+       abstract_cell.appendChild(mktext(abs));
 
 
 
        var resource = record.types_of_resource()[0];
+       if(resource.indexOf("sound recording") != -1) 
+               resource = "sound recording";
        var r_pic = elem("img", 
                { src: "/images/" + resource + ".jpg" } );
        resource_cell.appendChild(r_pic);
@@ -336,9 +358,33 @@ RecordDetailPage.prototype.drawRecord = function(record) {
        resource_cell.appendChild(
                createAppTextNode(record.types_of_resource()));
 
-
        pic_cell.appendChild(this.mkImage(record));
 
+
+       var locs = record.online_loc();
+       if(locs && locs.length > 0){ 
+               var tab = pic_cell.parentNode.parentNode;
+               var loc_row = tab.insertRow(tab.rows.length);
+               var desc_cell =loc_row.insertCell(0);
+               add_css_class(desc_cell, "detail_item_label");
+               desc_cell.appendChild(mktext("Other Resources"));
+               var links_cell =loc_row.insertCell(1);
+
+               var found = new Array(); /* weed out duplicates */
+               /* online location field is of the form [link, title, link, title, ...] */
+               for(var i = 0; i!= locs.length; i++ ) {
+                       var ref = locs[i++]; 
+                       var ttl = locs[i];
+                       if(find_list(found,function(f){return (f==ref);}))
+                               continue;
+                       found.push(ref);
+                       var a = elem("a", {style:"text-decoration:underline",
+                                       target:"_blank",href:ref,title:ttl}, null, ttl);
+                       links_cell.appendChild(a);
+                       links_cell.appendChild(mktext(" "));
+               }
+       }
+
        var orgUnit = globalSelectedLocation;
        if(!orgUnit) orgUnit = globalLocation;
 
@@ -424,14 +470,18 @@ RecordDetailPage.prototype.drawCopyTrees = function(orgUnit, record) {
 /* displays a link to view info for the parent org 
        if showMe == true, we don't search for the parent, 
        but use the given orgUnit as the link point */
-RecordDetailPage.prototype.displayParentLink = function(orgUnit, record, showMe) {
-
-       var region = orgUnit;
-       if(!showMe)
-               region = findOrgUnit(orgUnit.parent_ou());
+RecordDetailPage.prototype.displayParentLink = function(orgUnit, record) {
 
        var href = this.parentLink;
        removeChildren(href);
+       var region = orgUnit;
+       if(region == null) return;
+
+       var depth = parseInt(findOrgType(region.ou_type()).depth());
+
+       if(depth < 2) return;
+
+       region = findOrgUnit(orgUnit.parent_ou());
 
        href.appendChild(createAppTextNode(
                "View Volumes/Copies for " + region.name()));
@@ -447,10 +497,7 @@ RecordDetailPage.prototype.displayParentLink = function(orgUnit, record, showMe)
                /* allows the above message to be displayed */
                setTimeout(function() { obj.displayTrees(region, record, true) }, 100); 
 
-               if(showMe)
-                       obj.displayParentLink(orgUnit, record);
-               else
-                       obj.displayParentLink(orgUnit, record, true);
+               obj.displayParentLink(null);
        }
 
        var reg_div = createAppElement("div");
index 61e44f5..4ca54e2 100644 (file)
@@ -34,7 +34,7 @@ RemoteRequest.prunePending = function(id) {
                        if( req.id != id )
                                tmpArray.push(req);
                        else {
-                               debug("Cleaning " + req.id );
+                               //debug("Cleaning " + req.id );
                                req.clean();
                        }
                }
index de3efae..1cebef7 100644 (file)
@@ -238,8 +238,8 @@ UserSession.prototype.updateEmail = function(email) {
 }
 
 
-UserSession.prototype.fleshMe = function() {
-       if(this.fleshed) return;
+UserSession.prototype.fleshMe = function(force) {
+       if(this.fleshed && !force) return;
 
        var req = new RemoteRequest(
                "open-ils.actor",
@@ -248,6 +248,7 @@ UserSession.prototype.fleshMe = function() {
 
        req.send(true);
        this.userObject = req.getResultObject();
+       this.username = this.userObject.usrname();
        this.fleshed = true;
 }
 
index 8d55e1e..032c71b 100644 (file)
@@ -1,5 +1,20 @@
 /* */
 
+
+/* these are the types of resource provided my MODS - used in virtual records */
+var resourceFormats = [ 
+       "text", 
+       "moving image",
+       "sound recording",
+       "software, multimedia",
+       "still images",
+       "cartographic",
+       "mixed material",
+       "notated music",
+       "three dimensional object" ];
+
+
+
 function findOrgDepth(type_id) {
 
        if(type_id == null || globalOrgTypes == null)
@@ -46,11 +61,25 @@ function _flattenOrgs(node) {
        }
 }
 
+var singleOrgCache = new Object();
 function findOrgUnit(org_id, branch) {
+
        if(org_id == null) return null;
        if(typeof org_id == 'object') return org_id;
-       if(globalOrgTree == null)
-               throw new EXArg("Need globalOrgTree");
+
+       /* if we don't have the global org tree, grab the org unit from the server */
+       var tree_exists = false;
+       try{if(globalOrgTree != null) tree_exists = true;}catch(E){}
+
+       if(!tree_exists) {
+               var org = singleOrgCache[org_id];
+               if(org) return org;
+               var r = new RemoteRequest(
+                       "open-ils.actor",
+                       "open-ils.actor.org_unit.retrieve", null, org_id);
+               r.send(true);
+               return r.getResultObject();
+       }
 
        if(orgArraySearcher == null)
                _flattenOrgs();
@@ -134,7 +163,7 @@ function modsFormatToMARC(format) {
                        return "ef";
                case "mixed material":
                        return "op";
-               case "notated muix":
+               case "notated music":
                        return "cd";
                case "three dimensional object":
                        return "r";
@@ -142,4 +171,124 @@ function modsFormatToMARC(format) {
        throw new EXLogic("Invalid format provided form modsFormatToMARC: " + format);
 }
 
+function MARCFormatToMods(format) {
+       switch(format) {
+
+               case "a":
+               case "t":
+                       return "text";
+
+               case "g":
+                       return "moving image";
+
+               case "i":
+               case "j":
+                       return "sound recording";
+
+               case "m":
+                       return "software, multimedia";
+
+               case "k":
+                       return "still images";
+
+               case "e":
+               case "f":
+                       return "cartographic";
+
+               case "o":
+               case "p":
+                       return "mixed material";
+
+               case "c":
+               case "d":
+                       return "notated music";
+
+               case "r":
+                       return "three dimensional object";
+       }
+       throw new EXLogic("Invalid format provided for MARCFormatToMods: " + format);
+}
+
+
+
+/* if callback exists, call is asynchronous and 
+       the returned item is passed to the callback... */
+function fetchRecord(id, callback) {
+       var req = new RemoteRequest(
+               "open-ils.search",
+               "open-ils.search.biblio.record.mods_slim.retrieve",
+               id );
+
+       if(callback) {
+               req.setCompleteCallback(
+                       function(req) {callback(req.getResultObject())});
+               req.send();
+       } else {
+               req.send(true);
+               return req.getResultObject();
+       }
+}
+
+/* if callback exists, call is asynchronous and 
+       the returned item is passed to the callback... */
+function fetchMetaRecord(id, callback) {
+       var req = new RemoteRequest(
+               "open-ils.search",
+               "open-ils.search.biblio.metarecord.mods_slim.retrieve",
+               id );
+
+       if(callback) {
+               req.setCompleteCallback(
+                       function(req) {callback(req.getResultObject())});
+               req.send();
+       } else {
+               req.send(true);
+               return req.getResultObject();
+       }
+}
 
+/* if callback exists, call is asynchronous and 
+       the returned item is passed to the callback... */
+/* XXX no method yet... */
+function fetchVolume(id, callback) {
+       var req = new RemoteRequest(
+               "open-ils.search",
+               "open-ils.search.biblio.metarecord.mods_slim.retrieve",
+               id );
+
+       if(callback) {
+               req.setCompleteCallback(
+                       function(req) {callback(req.getResultObject())});
+               req.send();
+       } else {
+               req.send(true);
+               return req.getResultObject();
+       }
+}
+
+/* if callback exists, call is asynchronous and 
+       the returned item is passed to the callback... */
+function fetchCopy(id, callback) {
+       var req = new RemoteRequest(
+               "open-ils.search",
+               "open-ils.search.asset.copy.fleshed.retrieve",
+               id );
+
+       if(callback) {
+               req.setCompleteCallback(
+                       function(req) {callback(req.getResultObject())});
+               req.send();
+       } else {
+               req.send(true);
+               return req.getResultObject();
+       }
+}
+
+function mkResourceImage(resource) {
+       var pic = elem("img");
+       pic.setAttribute("src", "/images/" + resource + ".jpg");
+       pic.setAttribute("width", "20");
+       pic.setAttribute("height", "20");
+       pic.setAttribute("title", resource);
+       return pic;
+}
index 512ca15..7bbea8b 100644 (file)
@@ -695,6 +695,7 @@ function removeChildren(node) {
                while(node.childNodes[0])
                        node.removeChild(node.childNodes[0]);
        }
+       return node;
 }
 
 
@@ -702,3 +703,26 @@ function removeChildren(node) {
 function userMessage(msg) {
        alert("An unknown error occured during the following process: " + msg);
 }
+
+
+
+/* returns [ xoffset, yoffset ] of the target node */
+function getXYOffsets(target) {
+
+       var x = findPosX(target);
+       var y = findPosY(target);
+       var height = getObjectHeight(target);
+       var xpos = x;
+
+       var offsety = y + height;
+       var offsetx = xpos; 
+       
+       if(IE) { /*HACK XXX*/
+               offsety = parseInt(offsety) + 15;
+               offsetx = parseInt(offsetx) + 8;
+       }
+
+       debug("getXYOffset y: " + offsety + " x: " + offsetx );
+       return [x, y];
+}
+
index e710b8b..afc624e 100644 (file)
@@ -13,6 +13,7 @@
                        js( src='/js/opac/MyOPACSPage.js' );
                        js( src='/js/util/RemoteRequest.js' );
                        js( src='/js/util/webutils.js' );
+                       js( src='/js/util/ils_utils.js' );
                        js( src='/js/util/UserSession.js' );
                        js( src='/js/util/Cookie.js' );
                        js( src='/js/util/ex.js' );
index 4854e8e..b01c542 100644 (file)
                                                                        cell(content="Subjects", class='detail_item_label');
                                                                        cell(id='record_detail_subject_cell');
                                                                END;
-                       
+
+                                                               WRAPPER html/row class='detail_item_row';
+                                                                       cell(content="Abstract", class='detail_item_label');
+                                                                       cell(id='record_detail_abstract_cell');
+                                                               END;
+
                                                        END; # table
                                                END;