From: phasefx Date: Fri, 17 Sep 2010 22:15:39 +0000 (+0000) Subject: change pcrud.apply to pcrud.update, and make use of closures in loop. fixes hanging... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4a88f5cdd30b0d998d629442b3ec12476b11eeac;p=evergreen%2Fpines.git change pcrud.apply to pcrud.update, and make use of closures in loop. fixes hanging progress bar and lack of list refresh in Messages interface after modifying or archiving an existing message/penalty git-svn-id: svn://svn.open-ils.org/ILS/trunk@17782 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/server/patron/standing_penalties.js b/Open-ILS/xul/staff_client/server/patron/standing_penalties.js index 75df88af34..1ddf2c4c27 100644 --- a/Open-ILS/xul/staff_client/server/patron/standing_penalties.js +++ b/Open-ILS/xul/staff_client/server/patron/standing_penalties.js @@ -292,7 +292,7 @@ function handle_edit_penalty(ev) { penalty.ischanged( 1 ); dojo.require('openils.PermaCrud'); var pcrud = new openils.PermaCrud( { authtoken :ses() }); - pcrud.apply( penalty, { + pcrud.update( penalty, { timeout : 10, // makes it synchronous onerror : function(r) { try { @@ -303,19 +303,21 @@ function handle_edit_penalty(ev) { alert(E); } }, - oncomplete : function(r) { - try { - var res = openils.Util.readResponse(r,true); - /* FIXME - test for success */ - var row_params = rows[ ids[i] ]; - row_params.row.my.ausp = penalty; - row_params.row.my.csp = penalty.standing_penalty(); - list.refresh_row( row_params ); - document.getElementById('progress').hidden = true; - } catch(E) { - alert(E); + oncomplete : function gen_func(p,row_id) { + return function(r) { + try { + var res = openils.Util.readResponse(r,true); + /* FIXME - test for success */ + var row_params = rows[row_id]; + row_params.row.my.ausp = p; + row_params.row.my.csp = p.standing_penalty(); + list.refresh_row( row_params ); + document.getElementById('progress').hidden = true; + } catch(E) { + alert(E); + } } - } + }(penalty,ids[i]) }); } } @@ -346,7 +348,7 @@ function handle_archive_penalty(ev) { penalty.stop_date( util.date.formatted_date(new Date(),'%F') ); dojo.require('openils.PermaCrud'); var pcrud = new openils.PermaCrud( { authtoken :ses() }); - pcrud.apply( penalty, { + pcrud.update( penalty, { onerror : function(r) { try { var res = openils.Util.readResponse(r,true); @@ -358,21 +360,23 @@ function handle_archive_penalty(ev) { document.getElementById('progress').hidden = true; } }, - oncomplete : function(r) { - try { - var res = openils.Util.readResponse(r,true); - /* FIXME - test for success */ - var node = rows[ ids[i] ].my_node; - var parentNode = node.parentNode; - parentNode.removeChild( node ); - delete(rows[ ids[i] ]); - } catch(E) { - alert(E); - } - if (--outstanding_requests==0) { - document.getElementById('progress').hidden = true; + oncomplete : function gen_func(row_id) { + return function(r) { + try { + var res = openils.Util.readResponse(r,true); + /* FIXME - test for success */ + var node = rows[row_id].my_node; + var parentNode = node.parentNode; + parentNode.removeChild( node ); + delete(rows[row_id]); + } catch(E) { + alert(E); + } + if (--outstanding_requests==0) { + document.getElementById('progress').hidden = true; + } } - } + }(ids[i]) }); } /*