Change labels such that they refer to Pending patrons instead of Staged patrons,...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 18 Nov 2009 07:25:39 +0000 (07:25 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 18 Nov 2009 07:25:39 +0000 (07:25 +0000)
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
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
Open-ILS/xul/staff_client/server/locale/en-US/patron.properties
Open-ILS/xul/staff_client/server/patron/staged.js
Open-ILS/xul/staff_client/server/patron/staged.xul

index bcec77f..d835258 100644 (file)
 <!ENTITY staff.main.menu.circ.offline.label "Enter Offline Interface">
 <!ENTITY staff.main.menu.circ.patron_registration.accesskey "R">
 <!ENTITY staff.main.menu.circ.patron_registration.label "Register Patron">
-<!ENTITY staff.main.menu.circ.staged_patrons.accesskey "t">
-<!ENTITY staff.main.menu.circ.staged_patrons.label "Staged Patrons">
+<!ENTITY staff.main.menu.circ.staged_patrons.accesskey "g">
+<!ENTITY staff.main.menu.circ.staged_patrons.label "Pending Patrons">
 <!ENTITY staff.main.menu.circ.patron_retrieve.accesskey "L">
 <!ENTITY staff.main.menu.circ.patron_retrieve.label "Retrieve Last Patron">
 <!ENTITY staff.main.menu.circ.patron_status.key "P">
 <!ENTITY staff.patron_display.archived_penalty.end_date.accesskey "">
 <!ENTITY staff.patron_display.archived_penalty.retrieve.label "Retrieve Archived Penalties">
 <!ENTITY staff.patron_display.archived_penalty.retrieve.accesskey "R">
-<!ENTITY staff.patron_display.staged.caption "Staged Patrons">
-<!ENTITY staff.patron_display.staged.menu.actions.label "Actions for Selected Events">
-<!ENTITY staff.patron_display.staged.menu.actions.accesskey "A">
-<!ENTITY staff.patron_display.staged.menu.actions.cancel.label "Cancel Patron">
+<!ENTITY staff.patron_display.staged.caption "Pending Patrons">
+<!ENTITY staff.patron_display.staged.menu.actions.cancel.label "Delete Patron">
 <!ENTITY staff.patron_display.staged.menu.actions.cancel.accesskey "">
 <!ENTITY staff.patron_display.staged.menu.actions.load.label "Load Patron">
 <!ENTITY staff.patron_display.staged.menu.actions.load.accesskey "P">
+<!ENTITY staff.patron_display.staged.limit.label "Limit:">
+<!ENTITY staff.patron_display.staged.limit.accesskey "t">
+<!ENTITY staff.patron_display.staged.home_lib.label "Home Library:">
+<!ENTITY staff.patron_display.staged.home_lib.accesskey "H">
+<!ENTITY staff.patron_display.staged.reload.label "Refresh">
+<!ENTITY staff.patron_display.staged.reload.accesskey "R">
 <!ENTITY staff.patron_display.trigger_event.caption "Modify Triggered Events">
 <!ENTITY staff.patron_display.trigger_event.menu.actions.label "Actions for Selected Events">
 <!ENTITY staff.patron_display.trigger_event.menu.actions.accesskey "A">
index de3d81f..06ba7ce 100644 (file)
@@ -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' },
index 3950db2..46b433a 100644 (file)
@@ -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
index eaf7ad2..2316cfc 100644 (file)
@@ -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.
index dd8f0f2..efa5998 100644 (file)
@@ -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() {
index 0ce14d6..ca01ed0 100644 (file)
@@ -33,6 +33,7 @@
     <commandset id="staged_cmds">
         <command id="cmd_load" disabled="true"/>
         <command id="cmd_cancel" disabled="true"/>
+        <command id="cmd_reload" />
     </commandset>
 
     <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
         <caption id="staged_caption" label="&staff.patron_display.staged.caption;"/>
         <vbox flex="0">
             <hbox flex="1">
-                <hbox id="lib_menu_placeholder" />
+                <vbox pack="center">
+                    <label value="&staff.patron_display.staged.limit.label;" accesskey="&staff.patron_display.staged.limit.accesskey;" control="limit" />
+                </vbox>
+                <textbox id="limit" type="number" value="100" oils_persist="value" />
+                <vbox pack="center">
+                    <label value="&staff.patron_display.staged.home_lib.label;" accesskey="&staff.patron_display.staged.home_lib.accesskey;" control="lib_menu" />
+                </vbox>
+                <hbox id="lib_menu_placeholder" oils_persist="value" />
+                <button command="cmd_reload" label="&staff.patron_display.staged.reload.label;" accesskey="&staff.patron_display.staged.reload.accesskey;" />
                 <spacer flex="1" />
                 <progressmeter id="progress" flex="1" hidden="true" mode="undetermined"/>
-<!--
-                <menubar>
-                    <menu label="&staff.patron_display.staged.menu.actions.label;" 
-                        accesskey="&staff.patron_display.staged.menu.actions.accesskey;" 
-                        style="-moz-user-focus: normal">
-                        <menupopup>
-                            <menuitem command="cmd_load" label="&staff.patron_display.staged.menu.actions.load.label;" accesskey="&staff.patron_display.staged.menu.actions.load.accesskey;"/>
-                            <menuitem command="cmd_cancel" label="&staff.patron_display.staged.menu.actions.cancel.label;" accesskey="&staff.patron_display.staged.menu.actions.cancel.accesskey;"/>
-                        </menupopup>
-                    </menu>
-                </menubar>
--->
                 <button command="cmd_load" label="&staff.patron_display.staged.menu.actions.load.label;" accesskey="&staff.patron_display.staged.menu.actions.load.accesskey;"/>
                 <button command="cmd_cancel" label="&staff.patron_display.staged.menu.actions.cancel.label;" accesskey="&staff.patron_display.staged.menu.actions.cancel.accesskey;"/>
             </hbox>