From 302faea421e55748fe20f69b5e09d7b2b4c737d4 Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 11 Nov 2009 09:13:02 +0000 Subject: [PATCH] Interface for viewing pending action/trigger notices for a patron, with the ability to reset or cancel the notices. git-svn-id: svn://svn.open-ils.org/ILS/trunk@14865 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 9 ++ .../staff_client/chrome/content/main/constants.js | 5 + Open-ILS/xul/staff_client/server/patron/display.js | 12 ++ .../xul/staff_client/server/patron/display.xul | 1 + .../staff_client/server/patron/display_horiz.xul | 1 + .../server/patron/display_horiz_overlay.xul | 1 + .../staff_client/server/patron/display_overlay.xul | 1 + .../staff_client/server/patron/trigger_events.js | 175 +++++++++++++++++++++ .../staff_client/server/patron/trigger_events.xul | 69 ++++++++ 9 files changed, 274 insertions(+) create mode 100644 Open-ILS/xul/staff_client/server/patron/trigger_events.js create mode 100644 Open-ILS/xul/staff_client/server/patron/trigger_events.xul diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 0e6c1812ac..134eb05751 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -1298,6 +1298,13 @@ + + + + + + + @@ -2619,6 +2626,8 @@ + + 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 0be3fae90c..1b0ea841da 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -143,6 +143,10 @@ const api = { 'FM_ATC_VOID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.abort' }, 'FM_ATC_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.retrieve', 'secure' : false }, 'FM_ATC_RETRIEVE_VIA_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.retrieve_by_lib', 'secure' : false }, + 'FM_ATEV_APROPOS_AHR' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.events.ahr', 'secure' : true }, + 'FM_ATEV_APROPOS_CIRC' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.events.circ', 'secure' : true }, + 'FM_ATEV_CANCEL' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.event.cancel.batch', 'secure' : false }, + 'FM_ATEV_RESET' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.event.reset.batch', 'secure' : false }, 'FM_AU_ID_RETRIEVE_VIA_BARCODE_OR_USERNAME' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.retrieve_id_by_barcode_or_username' }, 'FM_AU_IDS_RETRIEVE_VIA_HASH' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.search.advanced' }, 'FM_AU_LIST_RETRIEVE_VIA_GROUP' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.usergroup.members.retrieve' }, @@ -363,6 +367,7 @@ const urls = { 'XUL_STAT_CAT_EDIT' : '/xul/server/admin/stat_cat_editor.xhtml', 'XUL_SURVEY_WIZARD' : 'chrome://open_ils_staff_client/content/admin/survey_wizard.xul', 'XUL_TIMESTAMP_DIALOG' : '/xul/server/util/timestamp.xul', + 'XUL_TRIGGER_EVENTS' : '/xul/server/patron/trigger_events.xul', 'XUL_USER_BUCKETS' : '/xul/server/patron/user_buckets.xul', 'XUL_VERIFY_CREDENTIALS' : '/xul/server/main/verify_credentials.xul', 'XUL_VOLUME_BUCKETS' : '/xul/server/cat/volume_buckets.xul', diff --git a/Open-ILS/xul/staff_client/server/patron/display.js b/Open-ILS/xul/staff_client/server/patron/display.js index 70fe2676ec..b67ebc44ea 100644 --- a/Open-ILS/xul/staff_client/server/patron/display.js +++ b/Open-ILS/xul/staff_client/server/patron/display.js @@ -308,6 +308,18 @@ patron.display.prototype = { ); } ], + 'cmd_patron_info_triggered_events' : [ + ['command'], + function(ev) { + obj.right_deck.set_iframe( + urls.XUL_TRIGGER_EVENTS, + {}, + { + 'patron_id' : obj.patron.id() + } + ); + } + ], 'cmd_patron_info_stats' : [ ['command'], function(ev) { diff --git a/Open-ILS/xul/staff_client/server/patron/display.xul b/Open-ILS/xul/staff_client/server/patron/display.xul index c206603831..7c2931c0b3 100644 --- a/Open-ILS/xul/staff_client/server/patron/display.xul +++ b/Open-ILS/xul/staff_client/server/patron/display.xul @@ -96,6 +96,7 @@ + diff --git a/Open-ILS/xul/staff_client/server/patron/display_horiz.xul b/Open-ILS/xul/staff_client/server/patron/display_horiz.xul index 9bbee85d28..97814a7822 100644 --- a/Open-ILS/xul/staff_client/server/patron/display_horiz.xul +++ b/Open-ILS/xul/staff_client/server/patron/display_horiz.xul @@ -96,6 +96,7 @@ + diff --git a/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul b/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul index 577116754b..b150583e9e 100644 --- a/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul +++ b/Open-ILS/xul/staff_client/server/patron/display_horiz_overlay.xul @@ -90,6 +90,7 @@ + diff --git a/Open-ILS/xul/staff_client/server/patron/display_overlay.xul b/Open-ILS/xul/staff_client/server/patron/display_overlay.xul index 148d5d39b7..7796cb96ca 100644 --- a/Open-ILS/xul/staff_client/server/patron/display_overlay.xul +++ b/Open-ILS/xul/staff_client/server/patron/display_overlay.xul @@ -90,6 +90,7 @@ + diff --git a/Open-ILS/xul/staff_client/server/patron/trigger_events.js b/Open-ILS/xul/staff_client/server/patron/trigger_events.js new file mode 100644 index 0000000000..e43a0e0aca --- /dev/null +++ b/Open-ILS/xul/staff_client/server/patron/trigger_events.js @@ -0,0 +1,175 @@ +var list; var error; var net; var rows; var archived_rows; + +function $(id) { return document.getElementById(id); } + +//// parent interfaces often call these +function default_focus() { $('atev_list').focus(); } +function refresh() { populate_list(); } +//// + +function trigger_event_init() { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + + commonStrings = $('commonStrings'); + patronStrings = $('patronStrings'); + + if (typeof JSAN == 'undefined') { + throw( + commonStrings.getString('common.jsan.missing') + ); + } + + JSAN.errorLevel = "die"; // none, warn, or die + JSAN.addRepository('..'); + + JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve(); + XML_HTTP_SERVER = data.server_unadorned; + + JSAN.use('util.error'); error = new util.error(); + JSAN.use('util.network'); net = new util.network(); + JSAN.use('patron.util'); + JSAN.use('util.list'); + JSAN.use('util.functional'); + JSAN.use('util.widgets'); + + dojo.require('openils.Util'); + + init_list(); + $('cmd_cancel_event').addEventListener('command', gen_event_handler('cancel'), false); + $('cmd_reset_event').addEventListener('command', gen_event_handler('reset'), false); + populate_list(); + default_focus(); + + } catch(E) { + var err_prefix = 'trigger_events.js -> trigger_event_init() : '; + if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E); + } +} + +function gen_event_handler(method) { // cancel or reset? + return function(ev) { + try { + var sel = list.retrieve_selection(); + var ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ); } ); + + var pm = $('progress'); pm.value = 0; pm.hidden = false; + var idx = -1; + + var i = method == 'cancel' ? 'FM_ATEV_CANCEL' : 'FM_ATEV_RESET'; + fieldmapper.standardRequest( + [ api[i].app, api[i].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/trigger_events.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/trigger_events.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/trigger_events.js, handle_'+i+'_event oncomplete.',E); + } + pm.hidden = true; pm.value = 0; populate_list(); + } + } + ); + + } catch(E) { + alert('Error in patron/trigger_events.js, handle_???_event(): ' + E); + } + }; +} + +function init_list() { + try { + + list = new util.list( 'atev_list' ); + list.init( + { + 'columns' : [ 'atev' ], + 'retrieve_row' : retrieve_row, + 'on_select' : handle_selection + } + ); + + } catch(E) { + var err_prefix = 'trigger_events.js -> init_list() : '; + if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E); + } +} + +function retrieve_row(params) { // callback function for fleshing rows in a list + params.row_node.setAttribute('retrieve_id',params.row.my.atev.id()); + params.on_retrieve(params.row); + return params.row; +} + +function handle_selection(ev) { // handler for list row selection event + var sel = list.retrieve_selection(); + if (sel.length > 0) { + $('cmd_cancel_event').setAttribute('disabled','false'); + $('cmd_reset_event').setAttribute('disabled','false'); + } else { + $('cmd_cancel_event').setAttribute('disabled','true'); + $('cmd_reset_event').setAttribute('disabled','true'); + } +}; + +function populate_list() { + try { + + rows = {}; + list.clear(); + + function onResponse(r) { + var evt = openils.Util.readResponse(r); + var row_params = { + 'row' : { + 'my' : { + 'atev' : evt + } + } + }; + rows[ evt.id() ] = list.append( row_params ); + + } + + function onError(r) { + var evt = openils.Util.readResponse(r); + alert('error, evt = ' + js2JSON(evt)); + } + + var methods = ['FM_ATEV_APROPOS_CIRC','FM_ATEV_APROPOS_AHR']; + for (var i in methods) { + fieldmapper.standardRequest( + [api[methods[i]].app, api[methods[i]].method ], + { async: true, + params: [ses(), xul_param('patron_id')], + onresponse : onResponse, + onerror : onError, + oncomplete : function() {} + } + ); + } + + } catch(E) { + var err_prefix = 'trigger_events.js -> populate_list() : '; + if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E); + } +} diff --git a/Open-ILS/xul/staff_client/server/patron/trigger_events.xul b/Open-ILS/xul/staff_client/server/patron/trigger_events.xul new file mode 100644 index 0000000000..a133856157 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/patron/trigger_events.xul @@ -0,0 +1,69 @@ + + + + + + + + + + + + +]> + + + + + + + + + + + + +