From: phasefx Date: Wed, 29 Jul 2009 12:23:07 +0000 (+0000) Subject: action to archive selected penalties. Progressmeter isn't working like I'd expect... X-Git-Tag: sprint4-merge-nov22~9589 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=effcee82fbbec06c1f7fe804544c3cd1c30239a4;p=working%2FEvergreen.git action to archive selected penalties. Progressmeter isn't working like I'd expect, though git-svn-id: svn://svn.open-ils.org/ILS/trunk@13777 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index fa1e46c58b..e98d640491 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -1227,6 +1227,8 @@ + + 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 351fa59c26..9123ab65f8 100644 --- a/Open-ILS/xul/staff_client/server/patron/standing_penalties.js +++ b/Open-ILS/xul/staff_client/server/patron/standing_penalties.js @@ -34,6 +34,7 @@ function penalty_init() { document.getElementById('cmd_apply_penalty').addEventListener('command', handle_apply_penalty, false); document.getElementById('cmd_remove_penalty').addEventListener('command', handle_remove_penalty, false); document.getElementById('cmd_edit_penalty').addEventListener('command', handle_edit_penalty, false); + document.getElementById('cmd_archive_penalty').addEventListener('command', handle_archive_penalty, false); document.getElementById('cmd_retrieve_archived_penalties').addEventListener('command', handle_retrieve_archived_penalties, false); populate_list(); default_focus(); @@ -97,9 +98,11 @@ function generate_handle_selection(which_list) { if (ids.length > 0) { document.getElementById('cmd_remove_penalty').setAttribute('disabled','false'); document.getElementById('cmd_edit_penalty').setAttribute('disabled','false'); + document.getElementById('cmd_archive_penalty').setAttribute('disabled','false'); } else { document.getElementById('cmd_remove_penalty').setAttribute('disabled','true'); document.getElementById('cmd_edit_penalty').setAttribute('disabled','true'); + document.getElementById('cmd_archive_penalty').setAttribute('disabled','true'); } } }; @@ -299,6 +302,7 @@ function handle_edit_penalty(ev) { 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(); @@ -324,6 +328,62 @@ function handle_edit_penalty(ev) { } } +function handle_archive_penalty(ev) { + try { + var outstanding_requests = 0; + var sel = list.retrieve_selection(); + var ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ); } ); + if (ids.length > 0) { + document.getElementById('progress').hidden = false; + for (var i = 0; i < ids.length; i++) { + outstanding_requests++; + var penalty = util.functional.find_list( xulG.patron.standing_penalties(), function(o) { return o.id() == ids[i]; } ); + penalty.ischanged( 1 ); + penalty.stop_date( util.date.formatted_date(new Date(),'%F') ); + dojo.require('openils.PermaCrud'); + var pcrud = new openils.PermaCrud( { authtoken :ses() }); + pcrud.apply( penalty, { + onerror : function(r) { + try { + var res = openils.Util.readResponse(r,true); + error.standard_unexpected_error_alert(patronStrings.getString('staff.patron.standing_penalty.update_error'),res); + } catch(E) { + alert(E); + } + if (--outstanding_requests==0) { + 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; + } + } + }); + } + /* + if (xulG && typeof xulG.refresh == 'function') { + xulG.refresh(); + } + */ + } + + } catch(E) { + var err_prefix = 'standing_penalties.js -> handle_archive_penalty() : '; + if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E); + } +} + function handle_retrieve_archived_penalties() { try { document.getElementById('archived_progress').hidden = false; diff --git a/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul b/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul index 8c24dd2fe3..6cbe32ac0b 100644 --- a/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul +++ b/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul @@ -35,6 +35,7 @@ + @@ -75,6 +76,7 @@ + @@ -114,6 +116,7 @@ +