Add support for Holds and Items counts in dynamic staff Record Summary
authorJason Etheridge <jason@esilibrary.com>
Mon, 11 Jul 2011 11:22:01 +0000 (07:22 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 25 Jul 2011 20:57:38 +0000 (16:57 -0400)
(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 <jason@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.js
Open-ILS/xul/staff_client/server/locale/en-US/cat.properties

index 4d61b10..57c631c 100644 (file)
@@ -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' },
index b7dc24a..bc6d784 100644 (file)
@@ -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) {
index 6c4eb06..ee2912f 100644 (file)
@@ -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