From 29d1b357eef061bb3698e4ce0506eb93b63421be Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 2 Sep 2009 13:39:27 +0000 Subject: [PATCH] Simple in-client "activity log" interface (Admin -> Local Administration -> Work Log), and an example of such logging in the Checkout interface. The log function itself is part of util/error.js. Example: JSAN.use('util.error'); var logger = new util.error(); logger.work_log( "Staff member Foo circulated item Bar to patron Baz", // The log message // Additional Row data to pass to a util.list construct in the work log interface, which can be used in rendering columns, and accessed by actions acting on the list { au_id : 1, // Id for patron Baz; needed if you want the Retrieve Patron action to work with this log entry acp_barcode : 'Bar', // Barcode of the item; needed if you want the Retrieve Item action to work with this log entry } ); TODO: * Add logging statements to the Check In interface (complication there is that we don't have patron data, which would be useful) and Patron Registration * Possibly add explicit columns for the type of action, the item involved, the patron involved, and the staff involved (to compliment Operator Change), rather than just Message and When. * Add filtering support for action types git-svn-id: svn://svn.open-ils.org/ILS/trunk@13949 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 12 ++ .../chrome/content/OpenILS/global_util.js | 2 + .../staff_client/chrome/content/main/constants.js | 1 + .../xul/staff_client/chrome/content/main/menu.js | 12 +- .../chrome/content/main/menu_frame_menus.xul | 2 + .../xul/staff_client/chrome/content/util/error.js | 50 ++++++- .../chrome/locale/en-US/offline.properties | 1 + Open-ILS/xul/staff_client/server/admin/work_log.js | 161 +++++++++++++++++++++ .../xul/staff_client/server/admin/work_log.xul | 75 ++++++++++ Open-ILS/xul/staff_client/server/circ/checkout.js | 16 ++ Open-ILS/xul/staff_client/server/circ/util.js | 58 +++++++- .../server/locale/en-US/circ.properties | 3 + Open-ILS/xul/staff_client/server/patron/display.js | 1 + 13 files changed, 391 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/xul/staff_client/server/admin/work_log.js create mode 100644 Open-ILS/xul/staff_client/server/admin/work_log.xul diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index a8a20452b..3648812e2 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -171,6 +171,16 @@ + + + + + + + + + + @@ -624,6 +634,8 @@ + + diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js index f3cbb4ded..4cc94675c 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js @@ -3,6 +3,8 @@ function ses(a) { JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); switch(a) { + case 'staff_id' : return data.list.au[0].id(); break; + case 'staff_usrname' : return data.list.au[0].usrname(); break; case 'ws_ou' : return data.list.au[0].ws_ou(); break; 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 c2b6a1b92..6043e55f1 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -349,6 +349,7 @@ const urls = { 'XUL_VOLUME_BUCKETS' : '/xul/server/cat/volume_buckets.xul', 'XUL_VOLUME_COPY_CREATOR' : '/xul/server/cat/volume_copy_creator.xul', 'XUL_VOLUME_EDITOR' : '/xul/server/cat/volume_editor.xul', + 'XUL_WORK_LOG' : '/xul/server/admin/work_log.xul', 'XUL_Z3950_IMPORT' : '/xul/server/cat/z3950.xul', 'TEST_HTML' : '/xul/server/main/test.html', 'TEST_XUL' : '/xul/server/main/test.xul', diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index 838f8afd5..c8e3293dc 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -95,7 +95,7 @@ main.menu.prototype = { obj.set_tab( loc, {'tab_name' : label, 'browser' : false }, - {'no_xulG' : false, 'show_print_button' : false, show_nav_buttons:true} + {'no_xulG' : false, 'show_print_button' : false, 'show_nav_buttons' : true } ); } @@ -553,6 +553,16 @@ main.menu.prototype = { function() { open_eg_web_page('conify/global/config/hold_matrix_matchpoint', 'menu.local_admin.hold_matrix_matchpoint.tab'); } ], + 'cmd_local_admin_work_log' : [ + ['oncommand'], + function() { + obj.set_tab( + urls.XUL_WORK_LOG, + { 'tab_name' : offlineStrings.getString('menu.local_admin.work_log.tab') }, + {} + ); + } + ], 'cmd_server_admin_org_type' : [ ['oncommand'], function() { open_conify_page('actor/org_unit_type', null); } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul index f32be81bb..0599c1649 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul @@ -105,6 +105,7 @@ + @@ -292,6 +293,7 @@ + diff --git a/Open-ILS/xul/staff_client/chrome/content/util/error.js b/Open-ILS/xul/staff_client/chrome/content/util/error.js index bf0acadea..758b1557b 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/error.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/error.js @@ -552,7 +552,55 @@ util.error.prototype = { return false; // We can pass over low surrogates now as the second component in a pair which we have already processed } return str[i]; - } + }, + + 'work_log' : function(msg,row_data) { + try { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); + var max_entries = data.hash.aous['ui.admin.work_log.max_entries'] || 20; + if (! data.work_log) data.work_log = []; + if (! row_data) row_data = {}; + row_data.message = msg; + row_data.when = new Date(); + var ds = { + retrieve_id: js2JSON( { 'au_id' : row_data.au_id, 'au_barcode' : row_data.au_barcode, 'au_family_name' : row_data.au_family_name, 'acp_id' : row_data.acp_id, 'acp_barcode' : row_data.acp_barcode } ), + row: { my: row_data }, + to_top: true + }; + data.work_log.push( ds ); + if (data.work_log.length > max_entries) data.work_log.shift(); + data.stash('work_log'); + if (row_data.au_id) { + this.patron_log(msg,row_data); + } + } catch(E) { + try { this.standard_unexpected_error_alert('error in error.js, work_log(): ',E); } catch(F) { alert(E); } + } + }, + + 'patron_log' : function(msg,row_data) { + try { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); + var max_entries = data.hash.aous['ui.admin.patron_log.max_entries'] || 10; + if (! data.patron_log) data.patron_log = []; + if (! row_data) row_data = {}; + row_data.message = msg; + row_data.when = new Date(); + var ds = { + retrieve_id: js2JSON( { 'au_id' : row_data.au_id, 'au_barcode' : row_data.au_barcode, 'au_family_name' : row_data.au_family_name, 'acp_id' : row_data.acp_id, 'acp_barcode' : row_data.acp_barcode } ), + row: { my: row_data }, + to_top: true + }; + if (data.patron_log.length > 0) { + if ( data.patron_log[ data.patron_log.length -1 ].row.my.au_id == row_data.au_id ) data.patron_log.pop(); + } + data.patron_log.push( ds ); + if (data.patron_log.length > max_entries) data.patron_log.shift(); + data.stash('patron_log'); + } catch(E) { + try { this.standard_unexpected_error_alert('error in error.js, patron_log(): ',E); } catch(F) { alert(E); } + } + } } dump('exiting util/error.js\n'); 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 de91b628f..086d85cf8 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 @@ -227,3 +227,4 @@ menu.cmd_acq_view_exchange_rate.tab=Exchange Rates 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 diff --git a/Open-ILS/xul/staff_client/server/admin/work_log.js b/Open-ILS/xul/staff_client/server/admin/work_log.js new file mode 100644 index 000000000..8ae47c164 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/admin/work_log.js @@ -0,0 +1,161 @@ +var error; +var list1; var selected1 = []; +var list2; var selected2 = []; +var data; + +function my_init() { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); } + JSAN.errorLevel = "die"; // none, warn, or die + JSAN.addRepository('/xul/server/'); + JSAN.use('util.error'); error = new util.error(); + error.sdump('D_TRACE','my_init() for main_test.xul'); + + JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve(); + + init_lists(); + set_behavior(); + populate_lists(); + default_focus(); + + } catch(E) { + try { error.standard_unexpected_error_alert('admin/work_log.xul,my_init():',E); } catch(F) { alert(E); } + } +} + +function default_focus() { + var btn = document.getElementById('refresh_btn'); + if (btn) btn.focus(); +} + +function init_lists() { + try { + var cmd_retrieve_item = document.getElementById('cmd_retrieve_item'); + var cmd_retrieve_patron1 = document.getElementById('cmd_retrieve_patron1'); + var cmd_retrieve_patron2 = document.getElementById('cmd_retrieve_patron2'); + + JSAN.use('util.list'); + + list1 = new util.list('work_action_log'); + list2 = new util.list('work_patron_log'); + + JSAN.use('circ.util'); var columns = circ.util.work_log_columns({}); var column_mapper_func = circ.util.std_map_row_to_columns(); + + list1.init( { + 'columns' : columns, + 'map_row_to_columns' : column_mapper_func, + 'on_select' : function(ev) { + JSAN.use('util.functional'); var sel = list1.retrieve_selection(); + selected1 = util.functional.map_list( sel, function(o) { return JSON2js(o.getAttribute('retrieve_id')); }); + if (selected1.length == 0) { + cmd_retrieve_patron1.setAttribute('disabled','true'); + cmd_retrieve_item.setAttribute('disabled','true'); + } else { + cmd_retrieve_patron1.setAttribute('disabled','false'); + cmd_retrieve_item.setAttribute('disabled','false'); + } + } + } ); + + list2.init( { + 'columns' : columns, + 'map_row_to_columns' : column_mapper_func, + 'on_select' : function(ev) { + JSAN.use('util.functional'); var sel = list1.retrieve_selection(); + selected2 = util.functional.map_list( sel, function(o) { return JSON2js(o.getAttribute('retrieve_id')); }); + if (selected2.length == 0) { + cmd_retrieve_patron2.setAttribute('disabled','true'); + } else { + cmd_retrieve_patron2.setAttribute('disabled','false'); + } + } + } ); + + } catch(E) { + + try { error.standard_unexpected_error_alert('admin/work_log.xul,init_lists():',E); } catch(F) { alert(E); } + } +} + +function populate_lists() { + try { + list1.clear(); + data.stash_retrieve(); + if (data.work_log) { + for (var i = 0; i < data.work_log.length; i++ ) { + list1.append( data.work_log[i] ); + } + } + list2.clear(); + if (data.patron_log) { + for (var i = 0; i < data.patron_log.length; i++ ) { + list2.append( data.patron_log[i] ); + } + } + } catch(E) { + try { error.standard_unexpected_error_alert('admin/work_log.xul,populate_lists():',E); } catch(F) { alert(E); } + } +} + +function set_behavior() { + try { + var cmd_refresh = document.getElementById('cmd_refresh'); + var cmd_retrieve_item = document.getElementById('cmd_retrieve_item'); + var cmd_retrieve_patron1 = document.getElementById('cmd_retrieve_patron1'); + var cmd_retrieve_patron2 = document.getElementById('cmd_retrieve_patron2'); + + if (cmd_refresh) cmd_refresh.addEventListener('command', function() { populate_lists(); }, false); + + function gen_patron_retrieval_func(which) { + return function(ev) { + try { + var selected = which == 1 ? selected1 : selected2; + var seen = {}; + for (var i = 0; i < selected.length; i++) { + var patron_id = selected[i].au_id; + if (typeof patron_id == 'null') continue; + if (seen[patron_id]) continue; seen[patron_id] = true; + xulG.new_patron_tab( + {}, + { 'id' : patron_id } + ); + } + } catch(E) { + error.standard_unexpected_error_alert('Error in work_log.js, patron_retrieval_func():',E); + } + }; + } + if (cmd_retrieve_patron1) cmd_retrieve_patron1.addEventListener('command', gen_patron_retrieval_func(1), false); + if (cmd_retrieve_patron2) cmd_retrieve_patron2.addEventListener('command', gen_patron_retrieval_func(2), false); + + if (cmd_retrieve_item) cmd_retrieve_item.addEventListener( + 'command', + function(ev) { + try { + var seen = {}; var barcodes = []; + for (var i = 0; i < selected1.length; i++) { + var barcode = selected1[i].acp_barcode; + if (typeof barcode == 'null') continue; + if (seen[barcode]) continue; seen[barcode] = true; + barcodes.push( barcode ); + } + if (barcodes.length > 0) { + xulG.new_tab( + urls.XUL_COPY_STATUS, + {}, + { 'barcodes' : barcodes } + ); + } + } catch(E) { + error.standard_unexpected_error_alert('Error in work_log.js, retrieve_item():',E); + } + }, + false + ); + + } catch(E) { + try { error.standard_unexpected_error_alert('admin/work_log.xul,set_behavior():',E); } catch(F) { alert(E); } + } +} + diff --git a/Open-ILS/xul/staff_client/server/admin/work_log.xul b/Open-ILS/xul/staff_client/server/admin/work_log.xul new file mode 100644 index 000000000..a96c1cdb4 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/admin/work_log.xul @@ -0,0 +1,75 @@ + + + + + + + + + + + + +]> + + + + + + + + + + + + + +