Show copy status/location names in Vandelay items grid
authorBill Erickson <berick@esilibrary.com>
Thu, 4 Aug 2011 22:14:00 +0000 (18:14 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 9 Aug 2011 19:43:12 +0000 (15:43 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/web/js/ui/default/vandelay/vandelay.js
Open-ILS/web/templates/default/vandelay/inc/import_errors.tt2

index 97be36b..44898bb 100644 (file)
@@ -88,13 +88,15 @@ var vlBibSources = [];
 var importItemDefs = [];
 var matchSets = {};
 var mergeProfiles = [];
+var copyStatusCache = {};
+var copyLocationCache = {};
 
 /**
   * Grab initial data
   */
 function vlInit() {
     authtoken = openils.User.authtoken;
-    var initNeeded = 7; // how many async responses do we need before we're init'd 
+    var initNeeded = 8; // how many async responses do we need before we're init'd 
     var initCount = 0; // how many async reponses we've received
 
     openils.Util.registerEnterHandler(
@@ -184,6 +186,16 @@ function vlInit() {
         }
     );
 
+    new openils.PermaCrud().retrieveAll('ccs',
+        {   async: true,
+            oncomplete: function(r) {
+                var stats = openils.Util.readResponse(r);
+                dojo.forEach(stats, function(stat){copyStatusCache[stat.id()] = stat});
+                checkInitDone();
+            }
+        }
+    );
+
     vlAttrEditorInit();
     vlExportInit();
 }
@@ -792,6 +804,29 @@ function vlGetOrg(rowIdx, item) {
     return '';
 }
 
+function vlCopyStatus(rowIdx, item) {
+    if(!item) return '';
+    var value = this.grid.store.getValue(item, this.field);
+    if(value) return copyStatusCache[value].name();
+    return '';
+}
+
+// Note, we don't pre-fetch all copy locations because there could be 
+// a lot of them.  Instead, fetch-and-cache on demand.
+function vlCopyLocation(rowIdx, item) {
+    if(item) {
+        var value = this.grid.store.getValue(item, this.field);
+        if(value) {
+            if(!copyLocationCache[value]) {
+                copyLocationCache[value] = 
+                    new openils.PermaCrud().retrieve('acpl', value);
+            }
+            return copyLocationCache[value].name();
+        }
+    }
+    return '';
+}
+
 function vlFormatViewMatchMARC(id) {
     return '<a href="javascript:void(0);" onclick="vlLoadMARCHtml(' + id + ', true, '+
         'function(){displayGlobalDiv(\'vl-match-div\');});">' + this.name + '</a>';
index 5554f00..588260e 100644 (file)
@@ -37,6 +37,8 @@
                     <tr>
                         <th field='owning_lib' get='vlGetOrg'/>
                         <th field='circ_lib' get='vlGetOrg'/>
+                        <th field='status' get='vlCopyStatus'/>
+                        <th field='location' get='vlCopyLocation'/>
                     </tr>
                 </thead>
         </table>
@@ -69,6 +71,8 @@
                     <tr>
                         <th field='owning_lib' get='vlGetOrg'/>
                         <th field='circ_lib' get='vlGetOrg'/>
+                        <th field='status' get='vlCopyStatus'/>
+                        <th field='location' get='vlCopyLocation'/>
                     </tr>
                 </thead>
         </table>