[open-ils-commits] r17303 - trunk/Open-ILS/web/js/ui/default/cat/authority (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Aug 22 09:28:16 EDT 2010


Author: dbs
Date: 2010-08-22 09:28:14 -0400 (Sun, 22 Aug 2010)
New Revision: 17303

Modified:
   trunk/Open-ILS/web/js/ui/default/cat/authority/list.js
Log:
Show the number of bibs linked to each authority record

This information is important to cataloguers when deciding which records
to merge or delete.


Modified: trunk/Open-ILS/web/js/ui/default/cat/authority/list.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/cat/authority/list.js	2010-08-21 18:08:42 UTC (rev 17302)
+++ trunk/Open-ILS/web/js/ui/default/cat/authority/list.js	2010-08-22 13:28:14 UTC (rev 17303)
@@ -7,6 +7,7 @@
 dojo.require("dijit.Menu");
 dojo.require("dijit.MenuItem");
 dojo.require('dojox.xml.parser');
+dojo.require('DojoSRF');
 dojo.require("fieldmapper.Fieldmapper");
 dojo.require('openils.CGI');
 dojo.require('openils.PermaCrud');
@@ -29,6 +30,8 @@
 dojo.addOnLoad(authOUListInit);
 */
 function displayAuthorities(data) { 
+
+    var idArr = [];
     // Grab each record from the returned authority records
     dojo.query("record", data).forEach(function(node) {
         authText = '';
@@ -43,8 +46,10 @@
             authId = dojox.xml.parser.textContent(dfNode); 
         });
 
+        idArr.push(parseInt(authId));
+
         // Create the authority record listing entry
-        dojo.place('<div class="authEntry" id="auth' + authId + '"><span class="text">' + authText + '</span></div>', "authlist-div", "last");
+        dojo.place('<div class="authEntry" id="auth' + authId + '"><span class="text" id="authLabel' + authId + '">' + authText + '</span></div>', "authlist-div", "last");
 
         // Add the menu of new/edit/delete/mark-for-merge options
         var auth_menu = new dijit.Menu({});
@@ -87,12 +92,44 @@
             }
         }, "label":"Delete"}).placeAt(auth_menu, "last");
 
-        auth_mb = new dijit.form.DropDownButton({dropDown: auth_menu, label:"Actions"});
+        auth_mb = new dijit.form.DropDownButton({dropDown: auth_menu, label:"Actions", id:"menu" + authId});
         auth_mb.placeAt("auth" + authId, "first");
         auth_menu.startup();
     });
+
+    showBibCount(idArr);
+
 }
 
+function showBibCount(authIds) {
+    /* Decorate the list with # of bibs linked to each authority record */
+    var ses = new OpenSRF.ClientSession('open-ils.cat');
+    var req = ses.request('open-ils.cat.authority.records.count_linked_bibs', authIds);
+    var linkedIds = [];
+    req.oncomplete = function(r) {
+        var msg = r.recv().content();
+        dojo.forEach(msg, function(auth) {
+                linkedIds.push(auth.authority);
+                dojo.place('<span class="bibcount">' + auth.bibs + '</span>', 'authLabel' + auth.authority, 'before');
+            }
+        );
+
+        /* Assign counts of 0 for every non-linked authority */
+        dojo.forEach(authIds, function (id) {
+            var found = false;
+            dojo.forEach(linkedIds, function (lid) {
+                if (id == lid) {
+                    found = true;
+                }
+            });
+            if (!found) {
+                dojo.place('<span class="bibcount">0</span>', 'authLabel' + id, 'before');
+            }
+        });
+    }
+    req.send();
+}
+
 function loadMarcEditor(pcrud, rec) {
     /*
        To run in Firefox directly, must set signed.applets.codebase_principal_support



More information about the open-ils-commits mailing list