From 6303390551ddfb08834a70b21cb4bdfa31bf0673 Mon Sep 17 00:00:00 2001 From: dbs Date: Sun, 22 Aug 2010 13:28:14 +0000 Subject: [PATCH] Show the number of bibs linked to each authority record This information is important to cataloguers when deciding which records to merge or delete. git-svn-id: svn://svn.open-ils.org/ILS/trunk@17303 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/ui/default/cat/authority/list.js | 41 ++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/Open-ILS/web/js/ui/default/cat/authority/list.js b/Open-ILS/web/js/ui/default/cat/authority/list.js index 51462b522..37dc478a8 100644 --- a/Open-ILS/web/js/ui/default/cat/authority/list.js +++ b/Open-ILS/web/js/ui/default/cat/authority/list.js @@ -7,6 +7,7 @@ dojo.require('dijit.form.TextBox'); 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 @@ function authOUListInit() { 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 @@ function displayAuthorities(data) { authId = dojox.xml.parser.textContent(dfNode); }); + idArr.push(parseInt(authId)); + // Create the authority record listing entry - dojo.place('
' + authText + '
', "authlist-div", "last"); + dojo.place('
' + authText + '
', "authlist-div", "last"); // Add the menu of new/edit/delete/mark-for-merge options var auth_menu = new dijit.Menu({}); @@ -87,10 +92,42 @@ function displayAuthorities(data) { } }, "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('' + auth.bibs + '', '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('0', 'authLabel' + id, 'before'); + } + }); + } + req.send(); } function loadMarcEditor(pcrud, rec) { -- 2.11.0