added code to grab the copy locations
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 27 Jun 2005 15:19:15 +0000 (15:19 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 27 Jun 2005 15:19:15 +0000 (15:19 +0000)
added copy locations to the record details page

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

Open-ILS/src/javascript/opac/GlobalInit.js
Open-ILS/src/javascript/opac/MRResultPage.js
Open-ILS/src/javascript/opac/Page.js
Open-ILS/src/javascript/opac/RecordDetailPage.js
Open-ILS/src/javascript/util/ils_utils.js

index 327478c..022127a 100644 (file)
@@ -10,6 +10,7 @@ var globalSearchDepth                 = null;
 var globalMenuManager                  = null;
 var globalCopyStatus                           = null;
 var locationStack                                      = new Array();
+var globalCopyLocations                        = null;
 
 var lastSearchString                           = null;
 var lastSearchType                             = null;
@@ -205,8 +206,6 @@ function grabCopyStatus() {
        
                req.send();
        }
-
-
 }
 
 
index d36d745..65c927d 100644 (file)
@@ -340,23 +340,29 @@ MRResultPage.prototype.checkSpelling = function() {
 
        var response = request.getResultObject();
        if(response && response != "0") {
+
                debug("Received spell check response " + response );
 
-               var hcell = getById("hit_count_cell");
-               var href = createAppElement("a");
-               add_css_class(href,"record_result_author_link");
-               href.setAttribute("href",
-                       "?target=mr_result&mr_search_type=" + 
-                       this.stype + "&page=0&mr_search_query=" +
-                       encodeURIComponent(response));
-               href.appendChild(createAppTextNode(response));
-               href.title = "Search for " + response + "";
-               hcell.appendChild(createAppTextNode(" ... Did you mean "));
-               var ul = createAppElement("u");
-               hcell.appendChild(ul);
-               ul.appendChild(href);
-               hcell.appendChild(createAppTextNode("?"));
+               var dymb = getById("did_you_mean_box");
+               dymb.appendChild(elem("br"));
+
+               var ref = elem("a", 
+                       {
+                               href: "?target=mr_result&mr_search_type=" + 
+                                       this.stype + "&page=0&mr_search_query=" +
+                                       encodeURIComponent(response)
+                       } 
+               );
 
+               add_css_class(ref,"record_result_author_link");
+               ref.appendChild(createAppTextNode(response));
+               ref.title = "Search for " + response + "";
+
+               dymb.appendChild(createAppTextNode("Did you mean "));
+               var ul = createAppElement("u");
+               dymb.appendChild(ul);
+               ul.appendChild(ref);
+               dymb.appendChild(createAppTextNode("?"));
        }
 }
 
@@ -365,7 +371,8 @@ MRResultPage.prototype.doMRSearch = function() {
 
        var obj = this;
        var method = "open-ils.search.biblio.class";
-       /*
+
+       /* now the count and search are simultaneous 
        if( this.hitCount > 5000 )
                method = method + ".unordered";
                */
index 3cc7ff2..7404c58 100644 (file)
@@ -197,7 +197,8 @@ Page.prototype.buildNavBox = function(full) {
        try {
                if(globalOrgTree)
                        loc = elem("a", 
-                               {id:"location_nav_link", href:"javascript:void(0);"}, null, "Change Search Location");
+                               {id:"location_nav_link", href:"javascript:void(0);"}, 
+                               null, "Change Search Location");
 
                loc.onclick = function(evt) {
                        globalPage.locationTree.toggle(getById("location_nav_link"));
@@ -210,7 +211,7 @@ Page.prototype.buildNavBox = function(full) {
 
        arr.push(elem("a", {href: prefix + '?target=advanced_search'}, null, "Advanced Search"));
        arr.push(elem("a", {href: prefix + '?target=my_opac'}, null, "My OPAC"));
-       arr.push(elem("a", {href: prefix + '?target=about'}, null, "About PINES"));
+       //arr.push(elem("a", {href: prefix + '?target=about'}, null, "About PINES"));
        if(loc) arr.push(this.buildDeepLink());
 
        if(UserSession.instance().verifySession()) {
index 023eaf4..eb8aebf 100644 (file)
@@ -415,16 +415,19 @@ RecordDetailPage.prototype.displayCopyTree = function(tree, title) {
        var cell2       = row2.insertCell(row2.cells.length);
        var cell3       = row2.insertCell(row2.cells.length);
        var cell4       = row2.insertCell(row2.cells.length);
+       var cell5       = row2.insertCell(row2.cells.length);
 
-       cell1.appendChild(createAppTextNode("Callnumber"));
-       cell2.appendChild(createAppTextNode("Location"));
+       cell1.appendChild(createAppTextNode("Library"));
+       cell2.appendChild(createAppTextNode("Callnumber"));
        cell3.appendChild(createAppTextNode("Barcode(s)"));
-       cell4.appendChild(createAppTextNode("Availability"));
+       cell4.appendChild(createAppTextNode("Location"));
+       cell5.appendChild(createAppTextNode("Availability"));
 
        add_css_class(cell1, "detail_header_cell");
        add_css_class(cell2, "detail_header_cell");
        add_css_class(cell3, "detail_header_cell");
        add_css_class(cell4, "detail_header_cell");
+       add_css_class(cell5, "detail_header_cell");
 
        if(tree.length == 0) {
                var row = table.insertRow(table.rows.length);
@@ -432,6 +435,7 @@ RecordDetailPage.prototype.displayCopyTree = function(tree, title) {
                        createAppTextNode("No copies available for this location"));
        }
 
+       var libsVisited = new Array();
        var x = 0;
        for( var i in tree ) {
                var row = table.insertRow(table.rows.length);
@@ -440,11 +444,23 @@ RecordDetailPage.prototype.displayCopyTree = function(tree, title) {
 
                var cell1 = row.insertCell(row.cells.length);
                add_css_class(cell1, "detail_item_cell");
-               cell1.appendChild(createAppTextNode(volume.label()));
+
+
+               /* here we don't want to repeat the same libs name */
+               if(find_list( libsVisited,
+                               function(name) { 
+                               return (name == findOrgUnit(volume.owning_lib()).name()); })) {
+
+                       cell1.appendChild(createAppTextNode(" "));
+               } else {
+                       var name = findOrgUnit(volume.owning_lib()).name();
+                       cell1.appendChild(createAppTextNode(name));
+                       libsVisited.push(name);
+               }
+
                var cell2 = row.insertCell(row.cells.length);
                add_css_class(cell2, "detail_item_cell");
-               cell2.appendChild(createAppTextNode(
-                       findOrgUnit(volume.owning_lib()).name()));
+               cell2.appendChild(createAppTextNode(volume.label()));
 
                var cell3 = row.insertCell(row.cells.length);
                add_css_class(cell3, "detail_item_cell");
@@ -453,18 +469,29 @@ RecordDetailPage.prototype.displayCopyTree = function(tree, title) {
                var cell4 = row.insertCell(row.cells.length);
                add_css_class(cell4, "detail_item_cell");
                cell4.appendChild(createAppTextNode(" "));
+
+               var cell5 = row.insertCell(row.cells.length);
+               add_css_class(cell4, "detail_item_cell");
+               cell5.appendChild(createAppTextNode(" "));
                
                var copies = volume.copies();
                var c = 0;
+
                while(c < copies.length) {
+
                        var copy = copies[c];
+                       var loc = findCopyLocation(copy.location()).name();
+
                        if(c == 0) { /* put the first barcode in the same row as the callnumber */
 
-                               cell3.removeChild(cell3.childNodes[0]);
+                               removeChildren(cell3);
                                cell3.appendChild(createAppTextNode(copy.barcode()));
-                               cell4.removeChild(cell4.childNodes[0]);
 
-                               cell4.appendChild(createAppTextNode(
+                               removeChildren(cell4);
+                               cell4.appendChild(createAppTextNode(loc));
+
+                               removeChildren(cell5);
+                               cell5.appendChild(createAppTextNode(
                                        find_list(globalCopyStatus, 
                                                function(i) { return (i.id() == copy.status()); } ).name() ));
 
@@ -476,10 +503,15 @@ RecordDetailPage.prototype.displayCopyTree = function(tree, title) {
                                row.insertCell(1).appendChild(createAppTextNode(" "));
 
                                var ce = row.insertCell(2);
-                               var status_cell = row.insertCell(3);
+                               var loc_cell = row.insertCell(3);
+                               var status_cell = row.insertCell(4);
+
                                add_css_class(ce, "detail_item_cell");
+                               add_css_class(loc_cell, "detail_item_cell");
                                add_css_class(status_cell, "detail_item_cell");
+
                                ce.appendChild(createAppTextNode(copy.barcode()));
+                               loc_cell.appendChild(createAppTextNode(loc));
 
                                status_cell.appendChild(createAppTextNode(
                                        find_list(globalCopyStatus, 
index a6e4ace..1147c2f 100644 (file)
@@ -81,5 +81,34 @@ function findSiblingOrgs(node) {
 }
 
 
+function grabCopyLocations() {
+
+       if(globalCopyLocations != null) return;
+       debug("Grabbing copy locations");
+
+       var req = new RemoteRequest(
+               "open-ils.search",
+               "open-ils.search.config.copy_location.retrieve.all" );
+
+       req.send(true);
+       globalCopyLocations = req.getResultObject();
+       return globalCopyLocations;
+
+}
+
+function findCopyLocation(id) {
+
+       grabCopyLocations();
+       if(typeof id == 'object') return id;
+
+       if(globalCopyLocations == null) 
+               throw new EXLogic("globalCopyLocations is NULL");
+
+       for( var x = 0; x!= globalCopyLocations.length; x++) {
+               if(globalCopyLocations[x].id() == id)
+                       return globalCopyLocations[x];
+       }
+       return null;
+}