From 1cac5d630aa85f6923c7256a45bf23d5d191618c Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 18 Nov 2009 07:25:39 +0000 Subject: [PATCH] Change labels such that they refer to Pending patrons instead of Staged patrons, and change Cancel to Delete. Wire up the Delete action. Add a sticky number box for how many patrons to retrieve in lieu of paged navigation, and a Refresh button. Pig-trickery to make the Home Library selector sticky. Deleting or loading a patron removes the patron from the list. git-svn-id: svn://svn.open-ils.org/ILS/trunk@14950 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 16 ++-- .../staff_client/chrome/content/main/constants.js | 1 + .../chrome/locale/en-US/offline.properties | 2 +- .../server/locale/en-US/patron.properties | 4 +- Open-ILS/xul/staff_client/server/patron/staged.js | 105 ++++++++++++--------- Open-ILS/xul/staff_client/server/patron/staged.xul | 23 ++--- 6 files changed, 85 insertions(+), 66 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index bcec77f9a..d835258b8 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -789,8 +789,8 @@ - - + + @@ -1300,13 +1300,17 @@ - - - - + + + + + + + + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index de3d81ffd..06ba7ce06 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -241,6 +241,7 @@ const api = { 'FM_MOUS_RETRIEVE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fines.summary.authoritative', 'cacheable' : true, 'ttl' : 60000 }, 'FM_PGT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.groups.tree.retrieve', 'secure' : false }, 'FM_STGU_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.stage.retrieve.by_org', 'secure' : true }, + 'FM_STGU_DELETE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.stage.delete', 'secure' : false }, 'MARC_HTML_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.html', 'secure' : false }, 'FM_BLOB_RETRIEVE_VIA_Z3950_SEARCH' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.search_class' }, 'FM_BLOB_RETRIEVE_VIA_Z3950_RAW_SEARCH' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.search_service' }, diff --git a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties index 3950db28b..46b433a2d 100644 --- a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties +++ b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties @@ -235,6 +235,6 @@ menu.cmd_acq_view_distrib_formula.tab=Distribution Formulas menu.local_admin.circ_matrix_matchpoint.tab=Circulation Policies menu.local_admin.hold_matrix_matchpoint.tab=Hold Policies menu.local_admin.work_log.tab=Work Log -menu.circulation.staged_patrons.tab=Staged Patrons +menu.circulation.staged_patrons.tab=Pending Patrons load_printer_settings_error_description=Printer settings did not load cleanly with this version of Evergreen. You should reconfigure your printer under Printer Settings Editor. load_printer_settings_error_title=Printer Settings diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties index eaf7ad2f1..2316cfce3 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties @@ -318,7 +318,9 @@ staff.patron.summary.patron_net_access=Internet staff.patron.summary.expires_on=Expires on staff.patron.summary.standing_penalty.remove=Remove staff.patron.summary.standing_penalty.none=No Blocks/Penalties -staff.patron.staged.register_patron=Registering Staged Patron: %1$s +staff.patron.staged.register_patron=Registering Pending Patron: %1$s +staff.patron.staged.confirm_patron_delete=Delete the selected patrons? +staff.patron.staged.error_on_delete=Error deleting pending patron with row_id = %1$s staff.patron.staged.lib_menus.missing_library_list=Missing library list. staff.patron.standing_penalty.apply_error=Error applying %1$s block/standing penalty. staff.patron.standing_penalty.remove_error=Error removing %1$s block/standing penalty. diff --git a/Open-ILS/xul/staff_client/server/patron/staged.js b/Open-ILS/xul/staff_client/server/patron/staged.js index dd8f0f225..efa5998c4 100644 --- a/Open-ILS/xul/staff_client/server/patron/staged.js +++ b/Open-ILS/xul/staff_client/server/patron/staged.js @@ -1,4 +1,4 @@ -var list; var error; var net; var rows; var menu_lib; +var list; var error; var net; var rows; var row_id_usrname_map; var menu_lib; function $(id) { return document.getElementById(id); } @@ -41,6 +41,7 @@ function staged_init() { list.set_list_actions(); $('cmd_cancel').addEventListener('command', gen_event_handler('cancel'), false); $('cmd_load').addEventListener('command', gen_event_handler('load'), false); + $('cmd_reload').addEventListener('command', function() { populate_list(); }, false); populate_list(); default_focus(); @@ -61,13 +62,15 @@ function populate_lib_menu() { var file = new util.file('offline_ou_list'); if (file._file.exists()) { var list_data = file.get_object(); file.close(); - var ml = util.widgets.make_menulist( list_data[0], ses('ws_ou') ); + menu_lib = x.getAttribute('value') || ses('ws_ou'); + var ml = util.widgets.make_menulist( list_data[0], menu_lib ); ml.setAttribute('id','lib_menu'); x.appendChild( ml ); ml.addEventListener( 'command', function(ev) { menu_lib = ev.target.value; + x.setAttribute('value',ev.target.value); oils_persist(x); populate_list(); }, false @@ -84,12 +87,13 @@ function gen_event_handler(method) { // cancel or load? return function(ev) { try { var sel = list.retrieve_selection(); - var ids = util.functional.map_list( sel, function(o) { return o.getAttribute('retrieve_id'); } ); + var row_ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ).row_id; } ); + var usrnames = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ).usrname; } ); if (method == 'cancel') { - cancel( ids ); + cancel( row_ids ); } else { - load( ids ); + load( usrnames ); } } catch(E) { @@ -100,41 +104,35 @@ function gen_event_handler(method) { // cancel or load? function cancel(ids) { try { - var pm = $('progress'); pm.value = 0; pm.hidden = false; - var idx = -1; - fieldmapper.standardRequest( - [ api['FM_STGU_CANCEL'].app, api['FM_STGU_CANCEL'].method ], - { async: true, - params: [ses(), ids], - onresponse: function(r) { - try { - idx++; pm.value = Number( pm.value ) + 100/ids.length; - var result = openils.Util.readResponse(r); - if (typeof result.ilsevent != 'undefined') { throw(result); } - } catch(E) { - error.standard_unexpected_error_alert('In patron/staged.js, handle_'+i+'_event onresponse.',E); - } - }, - onerror: function(r) { - try { - var result = openils.Util.readResponse(r); - throw(result); - } catch(E) { - error.standard_unexpected_error_alert('In patron/staged.js, handle_'+i+'_event onerror.',E); - } - pm.hidden = true; pm.value = 0; populate_list(); - }, - oncomplete: function(r) { - try { - var result = openils.Util.readResponse(r); - } catch(E) { - error.standard_unexpected_error_alert('In patron/staged.js, handle_'+i+'_event oncomplete.',E); + if (! window.confirm( $('patronStrings').getString('staff.patron.staged.confirm_patron_delete') ) ) { return; } + var pm = $('progress'); pm.value = 0; pm.hidden = false; + var idx = 0; + + function gen_req_handler(id) { + return function(req) { + try { + idx++; pm.value = Number( pm.value ) + 100/ids.length; + if (idx == ids.length) { pm.value = 0; pm.hidden = true; } + var robj = req.getResultObject(); + if (robj == '1') { + var node = rows[ row_id_usrname_map[ id ] ].my_node; + var parentNode = node.parentNode; + parentNode.removeChild( node ); + delete(rows[ row_id_usrname_map[ id ] ]); + delete(row_id_usrname_map[ id ]); + } else { + alert( $('patronStrings').getFormattedString('staff.patron.staged.error_on_delete',[ id ]) ); } - pm.hidden = true; pm.value = 0; populate_list(); + } catch(E) { + alert('Error in staged.js, cancel patron request handler: ' + E); } } - ); + } + + for (var i = 0; i < ids.length; i++) { + net.simple_request('FM_STGU_DELETE', [ ses(), ids[i] ], gen_req_handler( ids[i] )); + } } catch(E) { alert('Error in staged.js, cancel(): ' + E); } @@ -145,7 +143,7 @@ function spawn_search(s) { xulG.new_patron_tab( {}, { 'doit' : 1, 'query' : s } ); } -function spawn_editor(p) { +function spawn_editor(p,func) { var url = urls.XUL_PATRON_EDIT; var loc = xulG.url_prefix( urls.XUL_REMOTE_BROWSER ); xulG.new_tab( @@ -161,20 +159,36 @@ function spawn_editor(p) { 'url_prefix' : xulG.url_prefix, 'new_tab' : xulG.new_tab, 'new_patron_tab' : xulG.new_patron_tab, + 'on_save' : function() { if (typeof func == 'function') { func(); } }, 'params' : p } } ); } -function load( ids ) { +function load( usrnames ) { try { + + function gen_on_save_handler(usrname) { + return function() { + try { + var node = rows[ usrname ].my_node; + var parentNode = node.parentNode; + parentNode.removeChild( node ); + delete(row_id_usrname_map[ rows[ usrname ].row.my.stgu.row_id() ]); + delete(rows[ usrname ]); + } catch(E) { + alert('Error in staged.js, load on save handler: ' + E); + } + } + } + var seen = {}; - for (var i = 0; i < ids.length; i++) { - if (! seen[ ids[i] ]) { - seen[ ids[i] ] = true; - spawn_editor( { 'stage' : ids[i] } ); + for (var i = 0; i < usrnames.length; i++) { + if (! seen[ usrnames[i] ]) { + seen[ usrnames[i] ] = true; + spawn_editor( { 'stage' : usrnames[i] }, gen_on_save_handler( usrnames[i] ) ); } } @@ -208,7 +222,7 @@ function init_list() { function retrieve_row(params) { // callback function for fleshing rows in a list try { - params.row_node.setAttribute('retrieve_id',params.row.my.stgu.usrname()); + params.row_node.setAttribute('retrieve_id',js2JSON( { 'row_id' : params.row.my.stgu.row_id(), 'usrname' : params.row.my.stgu.usrname() } )); params.on_retrieve(params.row); } catch(E) { alert('Error in staged.js, retrieve_row(): ' + E); @@ -230,7 +244,7 @@ function handle_selection(ev) { // handler for list row selection event function populate_list() { try { - rows = {}; + rows = {}; row_id_usrname_map = {}; list.clear(); function onResponse(r) { @@ -243,6 +257,7 @@ function populate_list() { } }; rows[ blob.user.usrname() ] = list.append( row_params ); + row_id_usrname_map[ blob.user.row_id() ] = blob.user.usrname(); } function onError(r) { @@ -253,7 +268,7 @@ function populate_list() { fieldmapper.standardRequest( [api['FM_STGU_RETRIEVE'].app, api['FM_STGU_RETRIEVE'].method ], { async: true, - params: [ses(), menu_lib || ses('ws_ou')], + params: [ses(), menu_lib || ses('ws_ou'), $('limit').value || 100], onresponse : onResponse, onerror : onError, oncomplete : function() { diff --git a/Open-ILS/xul/staff_client/server/patron/staged.xul b/Open-ILS/xul/staff_client/server/patron/staged.xul index 0ce14d676..ca01ed006 100644 --- a/Open-ILS/xul/staff_client/server/patron/staged.xul +++ b/Open-ILS/xul/staff_client/server/patron/staged.xul @@ -33,6 +33,7 @@ + @@ -41,21 +42,17 @@ - + + + + + + +