From 2796fc24e336f02b58b6fe2c55d4339dc313a588 Mon Sep 17 00:00:00 2001 From: phasefx Date: Fri, 15 Jun 2007 20:33:02 +0000 Subject: [PATCH] revert back to 7188 (rel_1_0_5) for this file for now.. this interface isn't as simple as Item Status and needs more thought wrt single row refresh and all the various actions available git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0@7437 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/server/patron/items.js | 142 ++++++++--------------- 1 file changed, 50 insertions(+), 92 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/patron/items.js b/Open-ILS/xul/staff_client/server/patron/items.js index 65f34decb4..4ce761f400 100644 --- a/Open-ILS/xul/staff_client/server/patron/items.js +++ b/Open-ILS/xul/staff_client/server/patron/items.js @@ -10,8 +10,6 @@ patron.items = function (params) { patron.items.prototype = { - 'list_circ_map' : {}, - 'init' : function( params ) { var obj = this; @@ -89,21 +87,21 @@ patron.items.prototype = { 'cmd_items_print2' : [ ['command'], function() { obj.items_print(2); } ], 'cmd_items_export' : [ ['command'], function() { obj.items_export(1); } ], 'cmd_items_export2' : [ ['command'], function() { obj.items_export(2); } ], - 'cmd_items_renew' : [ ['command'], function() { obj.items_renew(1); /* obj.retrieve();*/ } ], + 'cmd_items_renew' : [ ['command'], function() { obj.items_renew(1); /*alert('Action complete.'); obj.retrieve();*/ } ], 'cmd_items_renew_all' : [ ['command'], function() { obj.items_renew_all(); } ], - 'cmd_items_renew2' : [ ['command'], function() { obj.items_renew(2); /* obj.retrieve();*/ } ], - 'cmd_items_edit' : [ ['command'], function() { obj.items_edit(1); /*obj.retrieve();*/ } ], - 'cmd_items_edit2' : [ ['command'], function() { obj.items_edit(2); /*obj.retrieve();*/ } ], - 'cmd_items_mark_lost' : [ ['command'], function() { obj.items_mark_lost(1); /*obj.retrieve();*/ } ], - 'cmd_items_mark_lost2' : [ ['command'], function() { obj.items_mark_lost(2); /*obj.retrieve();*/ } ], - 'cmd_items_claimed_returned' : [ ['command'], function() { obj.items_claimed_returned(1); /*obj.retrieve();*/ } ], - 'cmd_items_claimed_returned2' : [ ['command'], function() { obj.items_claimed_returned(2); /*obj.retrieve();*/ } ], - 'cmd_items_checkin' : [ ['command'], function() { obj.items_checkin(1); /*obj.retrieve();*/ } ], - 'cmd_items_checkin2' : [ ['command'], function() { obj.items_checkin(2); /*obj.retrieve();*/ } ], + 'cmd_items_renew2' : [ ['command'], function() { obj.items_renew(2); /*alert('Action complete.'); obj.retrieve();*/ } ], + 'cmd_items_edit' : [ ['command'], function() { obj.items_edit(1); alert('Action complete.'); obj.retrieve(); } ], + 'cmd_items_edit2' : [ ['command'], function() { obj.items_edit(2); alert('Action complete.'); obj.retrieve(); } ], + 'cmd_items_mark_lost' : [ ['command'], function() { obj.items_mark_lost(1); alert('Action complete.'); obj.retrieve(); } ], + 'cmd_items_mark_lost2' : [ ['command'], function() { obj.items_mark_lost(2); alert('Action complete.'); obj.retrieve(); } ], + 'cmd_items_claimed_returned' : [ ['command'], function() { obj.items_claimed_returned(1); alert('Action complete.'); obj.retrieve(); } ], + 'cmd_items_claimed_returned2' : [ ['command'], function() { obj.items_claimed_returned(2); alert('Action complete.'); obj.retrieve(); } ], + 'cmd_items_checkin' : [ ['command'], function() { obj.items_checkin(1); alert('Action complete.'); obj.retrieve(); } ], + 'cmd_items_checkin2' : [ ['command'], function() { obj.items_checkin(2); alert('Action complete.'); obj.retrieve(); } ], 'cmd_show_catalog' : [ ['command'], function() { obj.show_catalog(1); } ], 'cmd_show_catalog2' : [ ['command'], function() { obj.show_catalog(2); } ], - 'cmd_add_billing' : [ ['command'], function() { obj.add_billing(1); /*obj.retrieve();*/ } ], - 'cmd_add_billing2' : [ ['command'], function() { obj.add_billing(2); /*obj.retrieve();*/ } ], + 'cmd_add_billing' : [ ['command'], function() { obj.add_billing(1); alert('Action complete.'); obj.retrieve(); } ], + 'cmd_add_billing2' : [ ['command'], function() { obj.add_billing(2); alert('Action complete.'); obj.retrieve(); } ], 'cmd_show_noncats' : [ ['command'], function() { obj.show_noncats(); } ], } } @@ -261,7 +259,7 @@ patron.items.prototype = { try { obj.list.select_all(); obj.items_renew(1,true); - setTimeout(function(){list.on_all_fleshed = null; /* obj.retrieve();*/ },0); + setTimeout(function(){list.on_all_fleshed = null; /*alert('Action complete.'); obj.retrieve();*/ },0); } catch(E) { obj.error.standard_unexpected_error_alert('2 All items were not likely renewed',E); } @@ -288,7 +286,7 @@ patron.items.prototype = { var count = 0; - function gen_renew(bc,circ_id) { + function gen_renew(bc) { var x = document.getElementById('renew_msgs'); if (x) { var l = document.createElement('label'); @@ -297,20 +295,16 @@ patron.items.prototype = { } var renew = circ.util.renew_via_barcode( barcode, obj.patron_id, function(r) { - if ( (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) { + if ( instanceOf( r[0], 'circ' ) || (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) { l.setAttribute('value', bc + ' renewed.'); - obj.list_circ_map[ circ_id ].row.my.circ = r[0].payload.circ; - obj.list_circ_map[ circ_id ].row.my.acp = r[0].payload.copy; - obj.list_circ_map[ circ_id ].row.my.mvr = r[0].payload.record; } else { - l.setAttribute('value', bc + ' not renewed. ' + r[0].textcode + ' : ' + r[0].desc); + l.setAttribute('value', bc + ' not renewed. ' + r[0].desc); } count--; if (count == 0) { - //if (window.confirm('Action completed. Refresh list?')) obj.retrieve(); + if (window.confirm('Action completed. Refresh list?')) obj.retrieve(); JSAN.use('util.widgets'); util.widgets.remove_children(x); } - obj.refresh(circ_id); } ); } @@ -319,8 +313,8 @@ patron.items.prototype = { try { count++; var barcode = retrieve_ids[i].barcode; - var circ_id = retrieve_ids[i].circ_id; - gen_renew(barcode,circ_id); + gen_renew(barcode); + } catch(E) { obj.error.standard_unexpected_error_alert('Renew probably did not happen for barcode ' + barcode,E); } @@ -377,9 +371,6 @@ patron.items.prototype = { if (typeof robj.ilsevent != 'undefined') { if (robj.ilsevent != 0) throw(robj); } } } - for (var i = 0; i < obj.retrieve_ids.length; i++) { - obj.refresh(retrieve_ids[i].circ_id); - } } catch(E) { obj.error.standard_unexpected_error_alert('The due dates were not likely modified.',E); } @@ -395,7 +386,6 @@ patron.items.prototype = { dump('Mark barcode lost = ' + barcode); var robj = obj.network.simple_request( 'MARK_ITEM_LOST', [ ses(), { barcode: barcode } ]); if (typeof robj.ilsevent != 'undefined') { if (robj.ilsevent != 0) throw(robj); } - obj.refresh(retrieve_ids[i].circ_id); } } catch(E) { obj.error.standard_unexpected_error_alert('The items were not likely marked lost.',E); @@ -452,7 +442,6 @@ patron.items.prototype = { if (typeof robj.ilsevent != 'undefined') { if (robj.ilsevent != 0) throw(robj); } } } - for (var i = 0; i < retrieve_ids.length; i++) obj.refresh(retrieve_ids[i].circ_id); } catch(E) { obj.error.standard_unexpected_error_alert('The items were not likely marked Claimed Returned.',E); } @@ -475,7 +464,6 @@ patron.items.prototype = { ses(), { 'copy_id' : copy_id } ); /* circ.util.checkin_via_barcode handles errors currently */ - obj.refresh(retrieve_ids[i].circ_id); } } catch(E) { obj.error.standard_unexpected_error_alert('Checkin probably did not happen.',E); @@ -566,46 +554,40 @@ patron.items.prototype = { return row; } - if (!row.my.circ) { - obj.network.simple_request( - 'FM_CIRC_DETAILS', - [ row.my.circ_id ], - function(req) { - try { - var robj = req.getResultObject(); - if (typeof robj.ilsevent != 'undefined') throw(robj); - if (typeof robj.ilsevent == 'null') throw('null result'); - row.my.circ = robj.circ; - row.my.acp = robj.copy; - row.my.mvr = robj.mvr; - row.my.acn = robj.volume; - - var copy_id = row.my.circ.target_copy(); - if (typeof copy_id == 'object') { - if (copy_id != null) { - copy_id = copy_id.id(); - } else { - if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id(); - } + obj.network.simple_request( + 'FM_CIRC_DETAILS', + [ row.my.circ_id ], + function(req) { + try { + var robj = req.getResultObject(); + if (typeof robj.ilsevent != 'undefined') throw(robj); + if (typeof robj.ilsevent == 'null') throw('null result'); + row.my.circ = robj.circ; + row.my.acp = robj.copy; + row.my.mvr = robj.mvr; + row.my.acn = robj.volume; + + var copy_id = row.my.circ.target_copy(); + if (typeof copy_id == 'object') { + if (copy_id != null) { + copy_id = copy_id.id(); } else { - if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id(); - } - - params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':copy_id,'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': (robj.record ? robj.record.id() : null) }) ); - - if (typeof params.on_retrieve == 'function') { - params.on_retrieve(row); + if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id(); } - } catch(E) { - obj.error.standard_unexpected_error_alert('Error in callback for FM_CIRC_DETAILS in patron/items.js',E); + } else { + if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id(); + } + + params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':copy_id,'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': (robj.record ? robj.record.id() : null) }) ); + + if (typeof params.on_retrieve == 'function') { + params.on_retrieve(row); } + } catch(E) { + obj.error.standard_unexpected_error_alert('Error in callback for FM_CIRC_DETAILS in patron/items.js',E); } - ); - } else { - if (typeof params.on_retrieve == 'function') { - params.on_retrieve(row); } - } + ); return row; } @@ -659,24 +641,6 @@ patron.items.prototype = { ); }, - 'refresh' : function(circ_id) { - var obj = this; - try { - var nparams = obj.list_circ_map[circ_id]; - var which_list = nparams.which_list; - switch(which_list) { - case 1: case '1': - setTimeout(function(){try{obj.list2.refresh_row(nparams);}catch(E){obj.error.standard_unexpected_error_alert('2 Error refreshing row in list\ncirc_id = ' + circ_id + '\nnparams = ' + nparams,E);}},1000); - break; - default: - setTimeout(function(){try{obj.list.refresh_row(nparams);}catch(E){obj.error.standard_unexpected_error_alert('2 Error refreshing row in list\ncirc_id = ' + circ_id + '\nnparams = ' + nparams,E);}},1000); - break; - } - } catch(E) { - obj.error.standard_unexpected_error_alert('Error refreshing row in list\ncirc_id = ' + circ_id + '\nnparams = ' + nparams,E); - } - }, - 'retrieve' : function(dont_show_me_the_list_change) { var obj = this; if (window.xulG && window.xulG.checkouts) { @@ -713,20 +677,14 @@ patron.items.prototype = { function gen_list_append(circ_id,which_list) { return function() { try { - var nparams; switch(which_list) { case 1: - nparams = obj.list2.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true, 'which_list' : which_list } ); + obj.list2.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true } ); break; default: - nparams = obj.list.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true, 'which_list' : which_list } ); + obj.list.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true } ); break; } - if (nparams) { - obj.list_circ_map[circ_id] = nparams; // unlike item status interface, each circ should be in this list only once - } else { - alert('foo'); - } } catch(E) { alert(E); } -- 2.11.0