From 6d4d47b3c971ed024334bea57c509f7326247594 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 11 Jul 2011 07:22:01 -0400 Subject: [PATCH] Add support for Holds and Items counts in dynamic staff Record Summary (use 'holds' and 'items' with your oils.bib_brief.*.dynamic_grid_replacement.data customizations) Also make the Bib Call # retrieval asynchronous and dependent on the field being configured for display. This branch has merged in (and depends on) the changes from collab/phasefx/dynamic_bib_brief Signed-off-by: Jason Etheridge Signed-off-by: Bill Erickson --- .../chrome/content/main/constants.js | 1 + .../server/cat/bib_brief_overlay.js | 92 +++++++++++++++---- .../server/locale/en-US/cat.properties | 5 + 3 files changed, 78 insertions(+), 20 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 4d61b10dec..57c631c988 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -139,6 +139,7 @@ var api = { 'FM_AHR_ONSHELF_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.captured_holds.on_shelf.retrieve' }, 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.captured_holds.id_list.on_shelf.retrieve', 'secure' : false }, 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.captured_holds.id_list.expired_on_shelf.retrieve', 'secure' : false }, + 'FM_AHR_COUNT_FOR_BRE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.bre.holds.count', 'secure' : false }, 'FM_AHR_COUNT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.hold_requests.count', 'cacheable' : true, 'ttl' : 60000 }, 'FM_AHR_COUNT_RETRIEVE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.hold_requests.count.authoritative', 'cacheable' : true, 'ttl' : 60000 }, 'FM_AHR_CANCEL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.cancel' }, diff --git a/Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.js b/Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.js index b7dc24a55b..bc6d784148 100644 --- a/Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.js +++ b/Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.js @@ -35,6 +35,10 @@ function bib_brief_overlay(params) { } JSAN.use('util.widgets'); + function exists(name) { + var nodes = document.getElementsByAttribute('name',name); + return nodes.length > 0; + } function set(name,value) { if (params.print_data) { params.print_data[name] = value; @@ -90,28 +94,76 @@ function bib_brief_overlay(params) { } } - // Let's fetch a bib call number - JSAN.use('OpenILS.data'); - var data = new OpenILS.data(); - var label_class = data.hash.aous['cat.default_classification_scheme']; - if (!label_class) { - label_class = 1; - } - var cn_blob_array = net.simple_request('BLOB_MARC_CALLNUMBERS_RETRIEVE',[params.mvr_id, label_class]); - if (! cn_blob_array) { cn_blob_array = []; } - var tooltip_text = ''; - for (var i = 0; i < cn_blob_array.length; i++) { - var cn_blob_obj = cn_blob_array[i]; - for (var j in cn_blob_obj) { - tooltip_text += j + ' : ' + cn_blob_obj[j] + '\n'; + // Let's fetch a bib call number, if the "bib_call_number" field exists + // in our display + if (exists('bib_call_number')) { + JSAN.use('OpenILS.data'); + var data = new OpenILS.data(); + var label_class = data.hash.aous[ + 'cat.default_classification_scheme' + ]; + if (!label_class) { + label_class = 1; } + net.simple_request( + 'BLOB_MARC_CALLNUMBERS_RETRIEVE', + [params.mvr_id, label_class], + function(req) { + var cn_blob_array = req.getResultObject(); + if (! cn_blob_array) { cn_blob_array = []; } + var tooltip_text = ''; + for (var i = 0; i < cn_blob_array.length; i++) { + var cn_blob_obj = cn_blob_array[i]; + for (var j in cn_blob_obj) { + tooltip_text += j + ' : ' + cn_blob_obj[j] + '\n'; + } + } + if (tooltip_text) { + var cn_blob_obj = cn_blob_array[0]; + for (var j in cn_blob_obj) { + set('bib_call_number',cn_blob_obj[j]); + } + set_tooltip('bib_call_number',tooltip_text); + } + } + ); } - if (tooltip_text) { - var cn_blob_obj = cn_blob_array[0]; - for (var j in cn_blob_obj) { - set('bib_call_number',cn_blob_obj[j]); - } - set_tooltip('bib_call_number',tooltip_text); + + // Let's fetch the hold count for the bib, if the "holds" field exists + // in our display + if (exists('holds')) { + net.simple_request( + 'FM_AHR_COUNT_FOR_BRE', + [params.mvr_id], + function(req) { + var hold_count = req.getResultObject(); + set('holds',hold_count); + } + ); + } + + // Let's fetch the item count for the bib, if the "items" field exists + // in our display + if (exists('items')) { + JSAN.use('OpenILS.data'); + var data = new OpenILS.data(); + net.simple_request( + 'FM_ACP_COUNT.authoritative', + [ data.tree.aou.id(), params.mvr_id ], + function(req){ + var count_blob = req.getResultObject()[0]; + set('items',count_blob.count); + set_tooltip( + 'items', + $('catStrings') + ? $('catStrings').getFormattedString( + 'staff.cat.bib_brief.items.available.tooltip', + [count_blob.available] + ) + : count_blob.available + ); + } + ); } } catch(E) { diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties index 6c4eb065e3..ee2912f677 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties @@ -542,3 +542,8 @@ staff.cat.bib_brief.editor.label=Last Edited By: staff.cat.bib_brief.editor.accesskey= staff.cat.bib_brief.edit_date.label=Last Edited On: staff.cat.bib_brief.edit_date.accesskey= +staff.cat.bib_brief.holds.label=Holds: +staff.cat.bib_brief.holds.accesskey= +staff.cat.bib_brief.items.label=Items: +staff.cat.bib_brief.items.accesskey= +staff.cat.bib_brief.items.available.tooltip=%1$s available -- 2.43.2