reduce network calls, and put back just-in-case network call for retrieving call...
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 6 Feb 2007 05:35:27 +0000 (05:35 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 6 Feb 2007 05:35:27 +0000 (05:35 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6897 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/cat/copy_summary.xul
Open-ILS/xul/staff_client/server/circ/copy_details.xul
Open-ILS/xul/staff_client/server/circ/util.js

index 9f786f5..46dfc4c 100644 (file)
                                if (g.data.temp_copy) {
                                        copy = g.data.temp_copy; g.data.temp_copy = null; g.data.stash('temp_copy');
                                }
+                               var callnumber;
+                               if (g.data.temp_callnumber) {
+                                       callnumber = g.data.temp_callnumber; g.data.temp_callnumber = null; g.data.stash('temp_callnumber');
+                               }
 
                                $('caption').setAttribute('tooltiptext','Copy ID = ' + (copy_id || copy.id() ) );
 
                                        try {
                                                var copy = req.getResultObject();
                                                if (typeof copy.ilsevent != 'undefined') throw(copy);
-                                               g.list.append({'row':{'my':{'acp':copy}}});
-                                               g.network.simple_request(
-                                                       'FM_ACN_RETRIEVE',
-                                                       [ copy.call_number() ],
-                                                       function (rreq) {
-                                                               try {
-                                                                       $w('barcode',copy.barcode());   
-                                                                       $w('ref',get_bool(copy.ref()) ? 'Yes' : 'No');  
-                                                                       $w('opac_visible',get_bool(copy.opac_visible()) ? 'Yes' : 'No');        
-                                                                       $w('circulate',get_bool(copy.circulate()) ? 'Yes' : 'No');      
-                                                                       $w('holdable',get_bool(copy.holdable()) ? 'Yes' : 'No');        
-                                                                       $w('age_protect',copy.age_protect() == null ? '<Unset>' : ( typeof copy.age_protect() == 'object' ? copy.age_protect().name() : g.data.hash.crahp[ copy.age_protect() ].name() ) );     
-                                                                       $w('location',typeof copy.location() == 'object' ? copy.location().name() : g.data.lookup('acpl',copy.location()).name() );     
-                                                                       $w('create_date',util.date.formatted_date(copy.create_date(),'%F'));
-                                                                       $w('edit_date',util.date.formatted_date(copy.edit_date(),'%F'));
-                                                                       $w('status',typeof copy.status() == 'object' ? copy.status().name() : g.data.hash.ccs[ copy.status() ].name() );        
-                                                               } catch(E) {
-                                                                       g.error.standard_unexpected_error_alert('rendering copy',E);
-                                                               }
-                                                               try {
-                                                                       var cn = rreq.getResultObject();
-                                                                       if (typeof cn.ilsevent != 'undefined') {
-                                                                               switch(cn.ilsevent) {
-                                                                                       case 1508 /* ASSET_CALL_NUMBER_NOT_FOUND */ :
-                                                                                               $w('callnumber','Not Cataloged');       
-                                                                                       break;
-                                                                                       default:
-                                                                                               throw(cn);
-                                                                                       break;
-                                                                               }
-                                                                       } else {
-                                                                               $w('callnumber',cn.label());    
+
+                                               function acn_callback(rreq) {
+                                                       try {
+                                                               $w('barcode',copy.barcode());   
+                                                               $w('ref',get_bool(copy.ref()) ? 'Yes' : 'No');  
+                                                               $w('opac_visible',get_bool(copy.opac_visible()) ? 'Yes' : 'No');        
+                                                               $w('circulate',get_bool(copy.circulate()) ? 'Yes' : 'No');      
+                                                               $w('holdable',get_bool(copy.holdable()) ? 'Yes' : 'No');        
+                                                               $w('age_protect',copy.age_protect() == null ? '<Unset>' : ( typeof copy.age_protect() == 'object' ? copy.age_protect().name() : g.data.hash.crahp[ copy.age_protect() ].name() ) );     
+                                                               $w('location',typeof copy.location() == 'object' ? copy.location().name() : g.data.lookup('acpl',copy.location()).name() );     
+                                                               $w('create_date',util.date.formatted_date(copy.create_date(),'%F'));
+                                                               $w('edit_date',util.date.formatted_date(copy.edit_date(),'%F'));
+                                                               $w('status',typeof copy.status() == 'object' ? copy.status().name() : g.data.hash.ccs[ copy.status() ].name() );        
+                                                       } catch(E) {
+                                                               g.error.standard_unexpected_error_alert('rendering copy',E);
+                                                       }
+                                                       try {
+                                                               var cn = rreq.getResultObject();
+                                                               if (typeof cn.ilsevent != 'undefined') {
+                                                                       switch(cn.ilsevent) {
+                                                                               case 1508 /* ASSET_CALL_NUMBER_NOT_FOUND */ :
+                                                                                       $w('callnumber','Not Cataloged');       
+                                                                               break;
+                                                                               default:
+                                                                                       throw(cn);
+                                                                               break;
                                                                        }
-                                                               } catch(E) {
-                                                                       g.error.standard_unexpected_error_alert('retrieving volume',E);
+                                                               } else {
+                                                                       $w('callnumber',cn.label());    
                                                                }
+                                                               g.list.append({'row':{'my':{'acp':copy,'acn':cn}}});
+                                                       } catch(E) {
+                                                               g.error.standard_unexpected_error_alert('retrieving volume',E);
                                                        }
-                                               );
+                                               }
+
+                                               if (callnumber) {
+                                                       acn_callback( { 'getResultObject' : function() { return callnumber; } } );
+                                               } else {
+                                                       g.network.simple_request(
+                                                               'FM_ACN_RETRIEVE',
+                                                               [ copy.call_number() ], acn_callback
+                                                       );
+                                               }
                                        } catch(E) {
                                                g.error.standard_unexpected_error_alert('retrieving copy',E);
                                        }
index 19139b6..3bb79a2 100644 (file)
@@ -66,7 +66,9 @@
                                //if (typeof g.callnumber.ilsevent != 'undefined') throw(g.callnumber);
 
                                $('top').setAttribute('src',urls.XUL_BIB_BRIEF + '?docid=' + g.callnumber.record());
-                               g.data.temp_copy = g.copy; g.data.stash('temp_copy'); $('item_summary').setAttribute('src',urls.XUL_COPY_SUMMARY);
+                               g.data.temp_copy = g.copy; g.data.stash('temp_copy'); 
+                               g.data.temp_callnumber = g.callnumber; g.data.stash('temp_callnumber'); 
+                               $('item_summary').setAttribute('src',urls.XUL_COPY_SUMMARY);
 
                                $('r_last').disabled = true;
                                if (g.circ) {
index 747872a..1b0e129 100644 (file)
@@ -431,7 +431,7 @@ circ.util.columns = function(modify,params) {
                },
                {
                        'id' : 'call_number', 'label' : getString('staff.acp_label_call_number'), 'flex' : 1,
-                       'primary' : false, 'hidden' : true, 'render' : function(my) { if (my.acp && my.acp.call_number() == -1) { return "Not Cataloged"; } else { if (!my.acn) { /* var x = network.simple_request("FM_ACN_RETRIEVE",[ my.acp.call_number() ]); if (x.ilsevent) { return "Not Cataloged"; } else { my.acn = x; return x.label(); } */ return '?'; } else { return my.acn.label(); } } },
+                       'primary' : false, 'hidden' : true, 'render' : function(my) { if (my.acp && my.acp.call_number() == -1) { return "Not Cataloged"; } else { if (!my.acn) { var x = network.simple_request("FM_ACN_RETRIEVE",[ my.acp.call_number() ]); if (x.ilsevent) { return "Not Cataloged"; } else { my.acn = x; return x.label(); } } else { return my.acn.label(); } } },
                        'persist' : 'hidden width ordinal',
                },
                {