From 9df2d18cb3c4859480ae454f37d24f1659e7c396 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 29 Oct 2014 17:07:02 -0400 Subject: [PATCH] KMAIN-383 - Added link to bib record Cross-port: 9982f43 --- .../var/templates_kcls/cat/authority/list_id.tt2 | 3 +- Open-ILS/web/js/ui/kcls/cat/authority/list_id.js | 78 +++++++++++++++------- 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/KCLS/openils/var/templates_kcls/cat/authority/list_id.tt2 b/KCLS/openils/var/templates_kcls/cat/authority/list_id.tt2 index 855e001ec0..cbc81fee9e 100644 --- a/KCLS/openils/var/templates_kcls/cat/authority/list_id.tt2 +++ b/KCLS/openils/var/templates_kcls/cat/authority/list_id.tt2 @@ -5,8 +5,9 @@ diff --git a/Open-ILS/web/js/ui/kcls/cat/authority/list_id.js b/Open-ILS/web/js/ui/kcls/cat/authority/list_id.js index e28627f590..6c9ef38bb4 100644 --- a/Open-ILS/web/js/ui/kcls/cat/authority/list_id.js +++ b/Open-ILS/web/js/ui/kcls/cat/authority/list_id.js @@ -101,7 +101,8 @@ function displayAuthorities(data) { dojo.place( '
' + '
' + - '' + auth.text + '
ID: ' + + '' + auth.text + '
ID: ' + auth.id + '
' + '
Control Set: ' + fetch_control_set(auth.thesaurus).name() + @@ -196,7 +197,7 @@ function displayAuthorities(data) { auth_menu.startup(); }); - showBibCount(idArr); + getAssociatedBibs(idArr); if (foundOne == 0) { window.alert("No Authority Record was found. \nPlease enter a valid Authority ID."); } @@ -254,33 +255,62 @@ function confirmDelete(recId) { } } -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 = []; +function getAssociatedBibs(authIds) { + var ses = new OpenSRF.ClientSession('open-ils.cat'); + var req = ses.request('open-ils.cat.authority.records.titled_linked_bibs', authIds); + 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, 'first'); - } - ); + for (var i in authIds){ + if (authIds[i] in msg){ + var count = 0; + for (var bib in msg[authIds[i]]){ + count ++; + dojo.place(' ', + 'auth' + authIds[i], + 'last'); + } + dojo.place('► ' + count + + '', + 'authLabel' + authIds[i], 'first'); + } + else{ + dojo.place('0 ', 'authLabel' + authIds[i], 'first'); + dojo.place('
-
', 'auth' + authIds[i], 'last'); + } + } + } + req.send(); +} - /* 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, 'first'); +function toggleBibsForAuthority(authId){ + var bibs = document.getElementsByClassName("forAuth" + authId); + var show = true; + for (var i in bibs){ + if (bibs[i] != undefined && bibs[i].style != undefined){ + if (bibs[i].style.visibility == "" || bibs[i].style.visibility == "hidden"){ + bibs[i].style.visibility = "visible"; + show = true; + } + else{ + bibs[i].style.visibility = "hidden"; + show = false; } - }); + } } - req.send(); + + var textToChange = document.getElementById("bibcount" + authId).innerHTML; + if (show){ + var changedText = textToChange.replace(textToChange.substring(0,1), String.fromCharCode(9660)); + } + else{ + var changedText = textToChange.replace(textToChange.substring(0,1), String.fromCharCode(9658)); + } + document.getElementById("bibcount" + authId).innerHTML = changedText; } function loadMarcEditor(pcrud, rec) { -- 2.11.0