backporting shortname print macro and holding maintenance fixes. and no_auto_select...
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 27 Mar 2007 01:57:11 +0000 (01:57 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 27 Mar 2007 01:57:11 +0000 (01:57 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0_4@7110 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
Open-ILS/xul/staff_client/chrome/content/util/print.js
Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js
Open-ILS/xul/staff_client/server/admin/transit_list.js
Open-ILS/xul/staff_client/server/cat/copy_browser.js

index 59e5404..2b6c7ca 100644 (file)
@@ -150,25 +150,25 @@ OpenILS.data.prototype = {
                                        'type' : 'items',
                                        'header' : 'The following items have been examined:<hr/><ol>',
                                        'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode%\r\n',
-                                       'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
+                                       'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
                                }, 
                                'transit_list' : {
                                        'type' : 'transits',
                                        'header' : 'Transits:<hr/><ol>',
                                        'line_item' : '<li>From: %transit_source% To: %transit_dest_lib%<br/>\r\nWhen: %transit_source_send_time%<br />\r\nBarcode: %transit_item_barcode% Title: %transit_item_title%<br/>\r\n',
-                                       'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
+                                       'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
                                }, 
                                'items_out' : {
                                        'type' : 'items',
                                        'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following items:<hr/><ol>',
                                        'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
-                                       'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
+                                       'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
                                }, 
                                'checkout' : {
                                        'type' : 'items',
                                        'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou checked out the following items:<hr/><ol>',
                                        'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
-                                       'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
+                                       'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
                                }, 
                                'offline_checkout' : {
                                        'type' : 'offline_checkout',
@@ -180,25 +180,25 @@ OpenILS.data.prototype = {
                                        'type' : 'items',
                                        'header' : 'You checked in the following items:<hr/><ol>',
                                        'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode%  Call Number: %call_number%\r\n',
-                                       'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
+                                       'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
                                }, 
                                'bill_payment' : {
                                        'type' : 'payment',
                                        'header' : 'Welcome to %LIBRARY%!<br/>A receipt of your  transaction:<hr/> <table width="100%"> <tr> <td>Original Balance:</td> <td align="right">$%original_balance%</td> </tr> <tr> <td>Payment Method:</td> <td align="right">%payment_type%</td> </tr> <tr> <td>Payment Received:</td> <td align="right">$%payment_received%</td> </tr> <tr> <td>Payment Applied:</td> <td align="right">$%payment_applied%</td> </tr> <tr> <td>Billings Voided:</td> <td align="right">%voided_balance%</td> </tr> <tr> <td>Change Given:</td> <td align="right">$%change_given%</td> </tr> <tr> <td>New Balance:</td> <td align="right">$%new_balance%</td> </tr> </table> <p> Note: %note% </p> <p> Specific bills: <blockquote>',
                                        'line_item' : 'Bill #%bill_id%  %last_billing_type% Received: $%payment%<br />%barcode% %title%<br /><br />',
-                                       'footer' : '</blockquote> </p> <hr />%PINES_CODE% %TODAY_TRIM%<br/> <br/> ',
+                                       'footer' : '</blockquote> </p> <hr />%SHORTNAME% %TODAY_TRIM%<br/> <br/> ',
                                },
                                'bills_historical' : {
                                        'type' : 'bills',
                                        'header' : 'Welcome to %LIBRARY%!<br/>You had the following bills:<hr/><ol>',
                                        'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
-                                       'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
+                                       'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
                                }, 
                                'bills_current' : {
                                        'type' : 'bills',
                                        'header' : 'Welcome to %LIBRARY%!<br/>You have the following bills:<hr/><ol>',
                                        'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
-                                       'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
+                                       'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
                                }, 
                                'offline_checkin' : {
                                        'type' : 'offline_checkin',
@@ -228,7 +228,7 @@ OpenILS.data.prototype = {
                                        'type' : 'holds',
                                        'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following titles on hold:<hr/><ol>',
                                        'line_item' : '<li>%title%\r\n',
-                                       'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
+                                       'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
                                } 
                        }; 
 
index d516b33..b4d6f9b 100644 (file)
@@ -154,6 +154,8 @@ util.print.prototype = {
                        catch(E){s = b; this.error.sdump('D_WARN','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
                try{b = s; s = s.replace(/%PINES_CODE%/,params.lib.shortname());}
                        catch(E){s = b; this.error.sdump('D_WARN','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{b = s; s = s.replace(/%SHORTNAME%/,params.lib.shortname());}
+                       catch(E){s = b; this.error.sdump('D_WARN','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
                try{b = s; s = s.replace(/%STAFF_FIRSTNAME%/,params.staff.first_given_name());}
                        catch(E){s = b; this.error.sdump('D_WARN','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
                try{b = s; s = s.replace(/%STAFF_LASTNAME%/,params.staff.family_name());}
index 2d20e1b..aed9b2a 100644 (file)
@@ -367,17 +367,23 @@ admin.offline_manage_xacts.prototype = {
 
        'check_perm' : function(perms) {
                var obj = this;
-               var robj = obj.network.simple_request('PERM_CHECK',[ses(),obj.data.list.au[0].id(),obj.data.list.au[0].ws_ou(),perms]);
-               if (typeof robj.ilsevent != 'undefined') {
-                       obj.error.standard_unexpected_error_alert('check permission',E);
-                       return false;
+               try {
+                       var robj = obj.network.simple_request('PERM_CHECK',[ses(),obj.data.list.au[0].id(),obj.data.list.au[0].ws_ou(),perms]);
+                       if (typeof robj.ilsevent != 'undefined') {
+                               obj.error.standard_unexpected_error_alert('check permission',E);
+                               return false;
+                       }
+                       return robj.length == 0 ? true : false;
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('Error checking permissions',E);
                }
-               return robj.length == 0 ? true : false;
        },
 
        'execute_ses' : function() {
                var obj = this;
 
+               try {
+
                clear_the_cache();
                obj.data.stash_retrieve();
 
@@ -393,17 +399,24 @@ admin.offline_manage_xacts.prototype = {
                        x.send(null);
 
                        dump(url + ' = ' + x.responseText + '\n' );
+                       if (!x.responseText) throw('Bad response from CGI component');
                        var robj = JSON2js(x.responseText);
 
                        if (robj.ilsevent != 0) { alert('Execute error: ' + x.responseText); }
 
                        obj.retrieve_seslist(); obj.render_seslist();
                }
+
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('Error executing session',E);
+               }
        },
 
        'ses_errors' : function() {
                var obj = this;
 
+               try {
+
                clear_the_cache();
                obj.data.stash_retrieve();
 
@@ -418,15 +431,23 @@ admin.offline_manage_xacts.prototype = {
                x.send(null);
 
                dump(url + ' = ' + x.responseText + '\n' );
+               if (!x.responseText) throw('Bad response from CGI component');
                var robj = JSON2js(x.responseText);
 
                return { 'errors' : robj, 'description' : obj.seslist[ obj.sel_list[0] ].description };
 
+               } catch(E) {
+                       throw('Error retrieving session errors: ' + E);
+               }
+
        },
 
        'rename_file' : function() {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                var obj = this;
+
+               try {
+
                JSAN.use('util.file'); 
                var pending = new util.file('pending_xacts');
                if ( !pending._file.exists() ) { throw("Can't rename a non-existent file"); }
@@ -439,29 +460,50 @@ admin.offline_manage_xacts.prototype = {
                        if (count++>100) throw("Taking too long to find a unique filename.");
                }
                pending._file.moveTo(null,obj.transition_filename);
+
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('Error renaming xact file',E);
+               }
        },
 
        'revert_file' : function() {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                var obj = this;
+
+               try {
+
                JSAN.use('util.file');
                var pending = new util.file('pending_xacts');
                if (pending._file.exists()) { obj.error.yns_alert('Something bad happened.  New offline transactions were accumulated during our attempted upload.  Tell your system admin that the file involved is ' + obj.transition_filename,'Scary Error','Ok',null,null,'Check here to confirm this message'); return; }
                var file = new util.file(obj.transition_filename);
                file._file.moveTo(null,'pending_xacts');
+
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('Error reverting xact file',E);
+               }
        },
 
        'archive_file' : function() {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                var obj = this;
+
+               try {
+
                JSAN.use('util.file');
                var file = new util.file(obj.transition_filename);
-               if (file._file.exists()) file._file.moveTo(null,obj.transition_filename + '.complete')
+               if (file._file.exists()) file._file.moveTo(null,obj.transition_filename + '.complete');
+
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('Error archiving xact file',E);
+               }
        },
 
        'upload' : function() {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                var obj = this;
+
+               try {
+
                if (obj.sel_list.length == 0) { alert('Please select a session to upload to.'); return; }
                if (obj.sel_list.length > 1) { alert('Please select a single session to upload to.'); return; }
 
@@ -517,11 +559,17 @@ admin.offline_manage_xacts.prototype = {
                        }
                };
                x.contentWindow.xulG = newG;
+
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('Error uploading xacts',E);
+               }
        },
 
        'ses_status' : function() {
                var obj = this;
 
+               try {
+
                clear_the_cache();
                obj.data.stash_retrieve();
 
@@ -536,15 +584,25 @@ admin.offline_manage_xacts.prototype = {
                x.send(null);
 
                dump(url + ' = ' + x.responseText + '\n' );
+               if (!x.responseText) throw('Bad response from CGI component');
                var robj = JSON2js(x.responseText);
 
                return robj;
+
+               } catch(E) {
+
+                       obj.error.standard_unexpected_error_alert('Error retrieving session status',E);
+                       return { 'ilsevent' : -2 };     
+
+               }
        },
 
        'create_ses' : function() {
 
                var obj = this;
 
+               try {
+
                var desc = window.prompt('Please enter a description:','','Create an Offline Transaction Session');
                if (desc=='' || desc==null) { return; }
 
@@ -561,12 +619,18 @@ admin.offline_manage_xacts.prototype = {
                x.send(null);
 
                dump(url + ' = ' + x.responseText + '\n' );
+               if (!x.responseText) throw('Bad response from CGI component');
                var robj = JSON2js(x.responseText);
                if (robj.ilsevent == 0) {
                        obj.retrieve_seslist(); obj.render_seslist();
                } else {
                        alert('Error: ' + x.responseText);
                }
+
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('Error creating session',E);
+               }
+
        },
 
        'retrieve_seslist' : function() {
@@ -587,11 +651,15 @@ admin.offline_manage_xacts.prototype = {
                        x.open("GET",url,false);
                        x.send(null);
 
-                       dump(url + ' = ' + x.responseText + '\n' );
+                       dump(url + ' = ' + typeof(x.responseText) + '\n' );
+
+                       if (!x.responseText) throw('Bad response from CGI component');
 
                        var robj = JSON2js( x.responseText );
                        if (typeof robj.ilsevent != 'undefined') throw(robj);
 
+                       if (!robj) throw(robj);
+
                        obj.seslist = robj.sort(
                                function(a,b) {
                                        return b.create_time - a.create_time;
@@ -607,6 +675,8 @@ admin.offline_manage_xacts.prototype = {
 
                var obj = this;
 
+               try {
+
                var old_idx = obj.list.node.currentIndex;
                if (old_idx < 0) old_idx = 0;
 
@@ -617,7 +687,7 @@ admin.offline_manage_xacts.prototype = {
                        funcs.push( 
                                function(idx,row){ 
                                        return function(){
-                                               obj.list.append( { 'retrieve_id' : idx, 'row' : row } );
+                                               obj.list.append( { 'retrieve_id' : idx, 'row' : row, 'no_auto_select' : true } );
                                                if (idx == old_idx) obj.list.node.view.selection.select(idx);
                                        };
                                }(i,{ 'my' : obj.seslist[i] }) 
@@ -630,16 +700,21 @@ admin.offline_manage_xacts.prototype = {
                document.getElementById('execute').disabled = true;
                document.getElementById('upload').disabled = true;
 
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('Error rendering session list',E);
+               }
        },
 
        'render_scriptlist' : function() {
 
                dump('render_scriptlist\n');
 
-               document.getElementById('deck').selectedIndex = 1;
-
                var obj = this;
 
+               try { 
+
+               document.getElementById('deck').selectedIndex = 1;
+
                obj.script_list.clear();
 
                var status = obj.ses_status();
@@ -652,23 +727,29 @@ admin.offline_manage_xacts.prototype = {
                        funcs.push( 
                                function(row){ 
                                        return function(){
-                                               obj.script_list.append( { 'row' : row } );
+                                               obj.script_list.append( { 'row' : row, 'no_auto_select' : true  } );
                                        };
                                }({ 'my' : scripts[i] }) 
                        );
                }
                JSAN.use('util.exec'); var exec = new util.exec();
                exec.chain( funcs );
+
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('Error rendering script list',E);
+               }
        },
        
        'render_errorlist' : function() {
 
                dump('render_errorlist\n');
 
-               document.getElementById('deck').selectedIndex = 2;
-
                var obj = this;
 
+               try {
+
+               document.getElementById('deck').selectedIndex = 2;
+
                obj.error_list.clear();
 
                var error_meta = obj.ses_errors();
@@ -681,13 +762,17 @@ admin.offline_manage_xacts.prototype = {
                        funcs.push( 
                                function(idx,row){ 
                                        return function(){
-                                               obj.error_list.append( { 'retrieve_id' : idx, 'row' : row } );
+                                               obj.error_list.append( { 'retrieve_id' : idx, 'row' : row, 'no_auto_select' : true  } );
                                        };
                                }(i,{ 'my' : obj.errors[i] }) 
                        );
                }
                JSAN.use('util.exec'); var exec = new util.exec();
                exec.chain( funcs );
+
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('Error rendering error list',E);
+               }
        },
 
        'render_status' : function() {
index b301a0b..10a6971 100644 (file)
@@ -37,8 +37,8 @@ admin.transit_list.prototype = {
                                                function gen_list_append(id,which_list) {
                                                        return function() {
                                                                switch(which_list) {
-                                                                       case 0: obj.list.append( { 'row' : { 'my' : { 'transit_id' : id } } } ); break;
-                                                                       case 1: obj.list2.append( { 'row' : { 'my' : { 'transit_id' : id } } } ); break;
+                                                                       case 0: obj.list.append( { 'row' : { 'my' : { 'transit_id' : id } }, 'no_auto_select' : true } ); break;
+                                                                       case 1: obj.list2.append( { 'row' : { 'my' : { 'transit_id' : id } }, 'no_auto_select' : true } ); break;
                                                                }
                                                        };
                                                }
index b0c916d..8c31a51 100644 (file)
@@ -874,7 +874,7 @@ cat.copy_browser.prototype = {
                                        'command',
                                        function(ev) {
                                                //obj.show_my_libs(ev.target.value);
-                                               JSAN.use('util.file'); var file = new util.file('copy_browser_prefs');
+                                               JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
                                                util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
                                                obj.refresh_list();
                                        },
@@ -886,14 +886,18 @@ cat.copy_browser.prototype = {
 
                        JSAN.use('util.widgets'); 
                
-                       file = new util.file('copy_browser_prefs');
+                       file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
                        util.widgets.load_attributes(file);
                        ml.value = ml.getAttribute('value');
+                       if (! ml.value) {
+                               ml.value = org.id();
+                               ml.setAttribute('value',ml.value);
+                       }
 
                        document.getElementById('show_acns').addEventListener(
                                'command',
                                function(ev) {
-                                       JSAN.use('util.file'); var file = new util.file('copy_browser_prefs');
+                                       JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
                                        util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
                                },
                                false
@@ -902,7 +906,7 @@ cat.copy_browser.prototype = {
                        document.getElementById('show_acps').addEventListener(
                                'command',
                                function(ev) {
-                                       JSAN.use('util.file'); var file = new util.file('copy_browser_prefs');
+                                       JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
                                        util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
                                },
                                false