refactoring.. moved some list print/clipboard functions into list.js
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 Dec 2007 22:54:45 +0000 (22:54 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 Dec 2007 22:54:45 +0000 (22:54 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@8231 dcc99617-32d9-48b4-a31d-7c20da2025e4

19 files changed:
Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js
Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js
Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js
Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js
Open-ILS/xul/staff_client/chrome/content/util/list.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_buckets.js
Open-ILS/xul/staff_client/server/cat/record_buckets.js
Open-ILS/xul/staff_client/server/cat/z3950.js
Open-ILS/xul/staff_client/server/circ/checkin.js
Open-ILS/xul/staff_client/server/circ/checkout.js
Open-ILS/xul/staff_client/server/circ/copy_status.js
Open-ILS/xul/staff_client/server/circ/hold_capture.js
Open-ILS/xul/staff_client/server/circ/in_house_use.js
Open-ILS/xul/staff_client/server/patron/bill_history.xul
Open-ILS/xul/staff_client/server/patron/holds.js
Open-ILS/xul/staff_client/server/patron/items.js
Open-ILS/xul/staff_client/server/patron/search_result.js

index 1538eef..3f77163 100644 (file)
@@ -107,26 +107,20 @@ function next_patron() {
 
                if ($('print_receipt').checked) {
                        try {
-                               var params = {
-                                       'header' : g.data.print_list_templates.offline_checkin.header,
-                                       'line_item' : g.data.print_list_templates.offline_checkin.line_item,
-                                       'footer' : g.data.print_list_templates.offline_checkin.footer,
-                                       'type' : g.data.print_list_templates.offline_checkin.type,
-                                       'list' : g.list.dump(),
-                               };
-                               JSAN.use('util.print'); var print = new util.print();
-                               print.tree_list( params );
+                var params = {
+                    'template' : 'offline_checkin',
+                    'callback' : function() {
+                        g.list.clear();
+                        var x = $('i_barcode'); x.value = ''; x.focus();
+                    }
+                };
+                g.list.print( params );
                        } catch(E) {
                                g.error.sdump('D_ERROR','print: ' + E);
                                alert('print: ' + E);
                        }
                }
 
-               g.list.clear();
-               
-               var x;
-               x = $('i_barcode'); x.value = ''; x.focus();
-
        } catch(E) {
                dump(E+'\n'); alert(E);
        }
index 1b7f59c..aebf4f1 100644 (file)
@@ -264,28 +264,21 @@ function next_patron(cancel) {
                        try {
                                var params = {
                                        'patron_barcode' : $('p_barcode').value,
-                                       'header' : g.data.print_list_templates.offline_checkout.header,
-                                       'line_item' : g.data.print_list_templates.offline_checkout.line_item,
-                                       'footer' : g.data.print_list_templates.offline_checkout.footer,
-                                       'type' : g.data.print_list_templates.offline_checkout.type,
-                                       'list' : g.list.dump(),
+                                       'template' : 'offline_checkout',
+                    'callback' : function() {
+                        g.list.clear();
+                        var x = $('i_barcode'); x.value = '';
+                        x = $('p_barcode'); x.value = ''; 
+                        x.setAttribute('disabled','false'); x.disabled = false; 
+                        x.focus();
+                    }
                                };
-                               JSAN.use('util.print'); var print = new util.print();
-                               print.tree_list( params );
+                               g.list.print( params );
                        } catch(E) {
                                g.error.sdump('D_ERROR','print: ' + E);
                                alert('print: ' + E);
                        }
                }
-
-               g.list.clear();
-               
-               var x;
-               x = $('i_barcode'); x.value = '';
-               x = $('p_barcode'); x.value = ''; 
-               x.setAttribute('disabled','false'); x.disabled = false; 
-               x.focus();
-
        } catch(E) {
                dump(E+'\n'); alert(E);
        }
index 01ab53b..5837f4a 100644 (file)
@@ -111,25 +111,18 @@ function next_patron() {
                if ($('print_receipt').checked) {
                        try {
                                var params = {
-                                       'header' : g.data.print_list_templates.offline_inhouse_use.header,
-                                       'line_item' : g.data.print_list_templates.offline_inhouse_use.line_item,
-                                       'footer' : g.data.print_list_templates.offline_inhouse_use.footer,
-                                       'type' : g.data.print_list_templates.offline_inhouse_use.type,
-                                       'list' : g.list.dump(),
+                                       'template' : 'offline_inhouse_use',
+                    'callback' : function() {
+                        g.list.clear();
+                        var x = $('i_barcode'); x.value = ''; x.focus();
+                    }
                                };
-                               JSAN.use('util.print'); var print = new util.print();
-                               print.tree_list( params );
+                               g.list.print( params );
                        } catch(E) {
                                g.error.sdump('D_ERROR','print: ' + E);
                                alert('print: ' + E);
                        }
                }
-
-               g.list.clear();
-               
-               var x;
-               x = $('i_barcode'); x.value = ''; x.focus();
-
        } catch(E) {
                dump(E+'\n'); alert(E);
        }
index 1437a7e..1892e1e 100644 (file)
@@ -223,27 +223,20 @@ function next_patron(cancel) {
                                        try {
                                                var params = {
                                                        'patron_barcode' : $('p_barcode').value,
-                                                       'header' : g.data.print_list_templates.offline_renew.header,
-                                                       'line_item' : g.data.print_list_templates.offline_renew.line_item,
-                                                       'footer' : g.data.print_list_templates.offline_renew.footer,
-                                                       'type' : g.data.print_list_templates.offline_renew.type,
-                                                       'list' : g.list.dump(),
+                                                       'template' : 'offline_renew',
+                            'callback' : function() {
+                                g.list.clear();
+                                var x = $('i_barcode'); x.value = '';
+                                x = $('p_barcode'); x.value = ''; x.focus();
+                            }
                                                };
-                                               JSAN.use('util.print'); var print = new util.print();
-                                               print.tree_list( params );
+                                               g.list.print( params );
                                        } catch(E) {
                                                g.error.sdump('D_ERROR','print: ' + E);
                                                alert('print: ' + E);
                                        }
                                }
                }
-
-               g.list.clear();
-               
-               var x;
-               x = $('i_barcode'); x.value = '';
-               x = $('p_barcode'); x.value = ''; x.focus();
-
        } catch(E) {
                dump(E+'\n'); alert(E);
        }
index da2fb2f..50327c2 100644 (file)
@@ -1080,6 +1080,47 @@ util.list.prototype = {
         }
     },
 
+    'print' : function(params) {
+        if (!params) params = {};
+               switch(this.node.nodeName) {
+                       case 'tree' : return this._print_tree(params); break;
+                       default: throw('NYI: Need ._print() for ' + this.node.nodeName); break;
+               }
+    },
+
+    '_print_tree' : function(params) {
+        var obj = this;
+        try {
+                       JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+            if (!params.staff && data.list.au && data.list.au[0]) {
+                params.staff = data.list.au[0];
+            }
+            if (!params.lib && data.list.au && data.list.au[0] && data.list.au[0].ws_ou() && data.hash.aou && data.hash.aou[ data.list.au[0].ws_ou() ]) {
+                params.lib = data.hash.aou[ data.list.au[0].ws_ou() ];
+                params.lib.children(null);
+            }
+            if (params.template && data.print_list_templates[ params.template ]) {
+                var template = data.print_list_templates[ params.template ];
+                for (var i in template) params[i] = template[i];
+            }
+            obj.wrap_in_full_retrieve(
+                function() {
+                    try {
+                        if (!params.list) params.list = obj.dump_with_keys();
+                        JSAN.use('util.print'); var print = new util.print();
+                        print.tree_list( params );
+                        if (typeof params.callback == 'function') params.callback();
+                    } catch(E) {
+                                   obj.error.standard_unexpected_error_alert('inner _print_tree',E);
+                    }
+                }
+            );
+            
+        } catch(E) {
+                       obj.error.standard_unexpected_error_alert('_print_tree',E);
+        }
+    },
+
        'dump_selected_with_keys' : function(params) {
                var obj = this;
                switch(this.node.nodeName) {
index 73f856a..cfb7a4c 100644 (file)
@@ -320,17 +320,7 @@ admin.offline_manage_xacts.prototype = {
                        'command',
                        function(ev) {
                                try {
-                                       obj.error_list.on_all_fleshed =
-                                               function() {
-                                                       try {
-                                                               dump( obj.error_list.dump_csv() + '\n' );
-                                                               copy_to_clipboard(obj.error_list.dump_csv());
-                                                               setTimeout(function(){ obj.error_list.on_all_fleshed = null; },0);
-                                                       } catch(E) {
-                                                               obj.error.standard_unexpected_error_alert('export',E); 
-                                                       }
-                                               }
-                                       obj.error_list.full_retrieve();
+                                       obj.error_list.dump_csv_to_clipboard();
                                } catch(E) {
                                        obj.error.standard_unexpected_error_alert('export',E); 
                                }
index fc66e3a..46ab60a 100644 (file)
@@ -421,37 +421,11 @@ admin.transit_list.prototype = {
        'print_list' : function(which_list) {
                var obj = this;
                try {
-
                        var list = which_list == 0 ? obj.list : obj.list2;
-
-                       if (list.on_all_fleshed != null) {
-                               var r = window.confirm('This list is busy retrieving/rendering rows for a pending action.  Would you like to abort the pending action and proceed?');
-                               if (!r) return;
-                       }
-                       list.on_all_fleshed =
-                               function() {
-                                       try {
-                                               dump( js2JSON( list.dump_with_keys() ) + '\n' );
-                                               obj.data.stash_retrieve();
-                                               var lib = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
-                                               lib.children(null);
-                                               var p = { 
-                                                       'lib' : lib,
-                                                       'staff' : obj.data.list.au[0],
-                                                       'header' : obj.data.print_list_templates.transit_list.header,
-                                                       'line_item' : obj.data.print_list_templates.transit_list.line_item,
-                                                       'footer' : obj.data.print_list_templates.transit_list.footer,
-                                                       'type' : obj.data.print_list_templates.transit_list.type,
-                                                       'list' : list.dump_with_keys(),
-                                               };
-                                               JSAN.use('util.print'); var print = new util.print();
-                                               print.tree_list( p );
-                                               setTimeout(function(){ list.on_all_fleshed = null; },0);
-                                       } catch(E) {
-                                               obj.error.standard_unexpected_error_alert('print',E); 
-                                       }
-                               }
-                       list.full_retrieve();
+            var p = { 
+                'template' : 'transit_list'
+            };
+                       list.print(p);
                } catch(E) {
                        obj.error.standard_unexpected_error_alert('print',E); 
                }
index 945d7eb..e37725c 100644 (file)
@@ -560,31 +560,13 @@ cat.copy_buckets.prototype = {
                                        'cmd_copy_buckets_export' : [
                                                ['command'],
                                                function() {
-                                                       obj.list2.on_all_fleshed = function() {
-                                                               try {
-                                                                       dump(obj.list2.dump_csv() + '\n');
-                                                                       copy_to_clipboard(obj.list2.dump_csv());
-                                                                       setTimeout(function(){obj.list2.on_all_fleshed = null;},0);
-                                                               } catch(E) {
-                                                                       alert(E); 
-                                                               }
-                                                       }
-                                                       obj.list2.full_retrieve();
+                                                       obj.list2.dump_csv_to_clipboard();
                                                }
                                        ],
                                        'cmd_export1' : [
                                                ['command'],
                                                function() {
-                                                       obj.list1.on_all_fleshed = function() {
-                                                               try {
-                                                                       dump(obj.list1.dump_csv() + '\n');
-                                                                       copy_to_clipboard(obj.list1.dump_csv());
-                                                                       setTimeout(function(){obj.list1.on_all_fleshed = null;},0);
-                                                               } catch(E) {
-                                                                       alert(E); 
-                                                               }
-                                                       }
-                                                       obj.list1.full_retrieve();
+                                                       obj.list1.dump_csv_to_clipboard();
                                                }
                                        ],
 
index c4ae5f3..4f60811 100644 (file)
@@ -391,32 +391,14 @@ cat.record_buckets.prototype = {
                                        'cmd_record_buckets_export' : [
                                                ['command'],
                                                function() {
-                                                       obj.list2.on_all_fleshed = function() {
-                                                               try {
-                                                                       dump(obj.list2.dump_csv() + '\n');
-                                                                       copy_to_clipboard(obj.list2.dump_csv());
-                                                                       setTimeout(function(){obj.list2.on_all_fleshed = null;},0);
-                                                               } catch(E) {
-                                                                       alert(E); 
-                                                               }
-                                                       }
-                                                       obj.list2.full_retrieve();
+                                                       obj.list2.dump_csv_to_clipboard();
                                                }
                                        ],
 
                                        'cmd_export1' : [
                                                ['command'],
                                                function() {
-                                                       obj.list1.on_all_fleshed = function() {
-                                                               try {
-                                                                       dump(obj.list1.dump_csv() + '\n');
-                                                                       copy_to_clipboard(obj.list1.dump_csv());
-                                                                       setTimeout(function(){obj.list1.on_all_fleshed = null;},0);
-                                                               } catch(E) {
-                                                                       alert(E); 
-                                                               }
-                                                       }
-                                                       obj.list1.full_retrieve();
+                                                       obj.list1.dump_csv_to_clipboard();
                                                }
                                        ],
 
index bc33c12..4cf522f 100644 (file)
@@ -82,16 +82,7 @@ cat.z3950.prototype = {
                                                'cmd_export' : [
                                                        ['command'],
                                                        function() {
-                                                               obj.list.on_all_fleshed = function() {
-                                                                       try {
-                                                                               dump(obj.list.dump_csv() + '\n');
-                                                                               copy_to_clipboard(obj.list.dump_csv());
-                                                                               setTimeout(function(){obj.list.on_all_fleshed = null;},0);
-                                                                       } catch(E) {
-                                                   obj.error.standard_unexpected_error_alert('Failure during export.',E);
-                                                                       }
-                                                               }
-                                                               obj.list.full_retrieve();
+                                                               obj.list.dump_csv_to_clipboard();
                                                        }
                                                ],
                                                'cmd_broken' : [
@@ -294,11 +285,11 @@ cat.z3950.prototype = {
                var obj = this;
                var x = obj.creds.services[service].default_attr;
                if (x) {
-                       document.getElementById(x+'_input').focus();
+                       var xx = document.getElementById(x+'_input'); if (xx) xx.focus();
                } else {
                        var y;
                        for (var i in obj.services[service].attr) { y = i; }
-                       document.getElementById(y+'_input').focus();
+                       var xx = document.getElementById(y+'_input'); if (xx) xx.focus();
                }
        },
 
index 05a6808..5068821 100644 (file)
@@ -236,44 +236,16 @@ circ.checkin.prototype = {
                                        'cmd_checkin_print' : [
                                                ['command'],
                                                function() {
-                                                       obj.list.on_all_fleshed = function() {
-                                                               try {
-                                                                       dump( js2JSON( obj.list.dump_with_keys() ) + '\n' );
-                                                                       obj.OpenILS.data.stash_retrieve();
-                                                                       var lib = obj.OpenILS.data.hash.aou[ obj.OpenILS.data.list.au[0].ws_ou() ];
-                                                                       lib.children(null);
-                                                                       var p = { 
-                                                                               'lib' : lib,
-                                                                               'staff' : obj.OpenILS.data.list.au[0],
-                                                                               'header' : obj.OpenILS.data.print_list_templates.checkin.header,
-                                                                               'line_item' : obj.OpenILS.data.print_list_templates.checkin.line_item,
-                                                                               'footer' : obj.OpenILS.data.print_list_templates.checkin.footer,
-                                                                               'type' : obj.OpenILS.data.print_list_templates.checkin.type,
-                                                                               'list' : obj.list.dump_with_keys(),
-                                                                       };
-                                                                       JSAN.use('util.print'); var print = new util.print();
-                                                                       print.tree_list( p );
-                                                                       setTimeout(function(){obj.list.on_all_fleshed = null;},0);
-                                                               } catch(E) {
-                                                                       alert(E); 
-                                                               }
-                                                       }
-                                                       obj.list.full_retrieve();
+                                                       var p = { 
+                                                               'template' : 'checkin'
+                                                       };
+                                                       obj.list.print(p);
                                                }
                                        ],
                                        'cmd_checkin_export' : [
                                                ['command'],
                                                function() {
-                                                       obj.list.on_all_fleshed = function() {
-                                                               try {
-                                                                       dump(obj.list.dump_csv() + '\n');
-                                                                       copy_to_clipboard(obj.list.dump_csv());
-                                                                       setTimeout(function(){obj.list.on_all_fleshed = null;},0);
-                                                               } catch(E) {
-                                                                       alert(E); 
-                                                               }
-                                                       }
-                                                       obj.list.full_retrieve();
+                                                       obj.list.dump_csv_to_clipboard();
                                                }
                                        ],
 
index d657ffb..6753f3c 100644 (file)
@@ -266,39 +266,25 @@ circ.checkout.prototype = {
                var obj = this;
                try {
                        obj.patron = obj.network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ses(),obj.patron_id]);
-                       dump( js2JSON( obj.list.dump_with_keys() ) + '\n' );
-                       obj.list.on_all_fleshed = function() {
-                               try {
-                                       var params = { 
-                                               'patron' : obj.patron, 
-                                               'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ],
-                                               'staff' : obj.data.list.au[0],
-                                               'header' : obj.data.print_list_templates.checkout.header,
-                                               'line_item' : obj.data.print_list_templates.checkout.line_item,
-                                               'footer' : obj.data.print_list_templates.checkout.footer,
-                                               'type' : obj.data.print_list_templates.checkout.type,
-                                               'list' : obj.list.dump_with_keys(),
-                                       };
-                                       if (silent) params.no_prompt = true;
-                                       JSAN.use('util.print'); var print = new util.print();
-                                       print.tree_list( params );
-                                       setTimeout(
-                                               function(){
-                                                       obj.list.on_all_fleshed = null;
-                                                       if (typeof f == 'function') { 
-                                                               setTimeout( 
-                                                                       function() {
-                                                                               f();
-                                                                       }, 1000
-                                                               )
-                                                       } }
-                                               , 1000
-                                       );
-                               } catch(E) {
-                                       obj.error.standard_unexpected_error_alert('print',E);
-                               }
-                       }
-                       obj.list.full_retrieve();
+            var params = { 
+                'patron' : obj.patron, 
+                'header' : 'checkout',
+                'callback' : function() {
+                    setTimeout(
+                        function(){
+                            if (typeof f == 'function') { 
+                                setTimeout( 
+                                    function() {
+                                        f();
+                                    }, 1000
+                                )
+                            } 
+                        }, 1000
+                    );
+                }
+            };
+                       if (silent) params.no_prompt = true;
+                       obj.list.print(params);
                } catch(E) {
                        obj.error.standard_unexpected_error_alert('print',E);
                }
@@ -307,16 +293,7 @@ circ.checkout.prototype = {
        'export_list' : function(silent,f) {
                var obj = this;
                try {
-                       obj.list.on_all_fleshed = function() {
-                               try {
-                                       dump( obj.list.dump_csv() + '\n' );
-                                       copy_to_clipboard(obj.list.dump_csv());
-                                       setTimeout(function(){obj.list.on_all_fleshed = null;if (typeof f == 'function') f();},0);
-                               } catch(E) {
-                                       obj.error.standard_unexpected_error_alert('print',E);
-                               }
-                       }
-                       obj.list.full_retrieve();
+                       obj.list.dump_csv_to_clipboard();
                } catch(E) {
                        obj.error.standard_unexpected_error_alert('export',E);
                }
index f173c45..ab8f8f0 100644 (file)
@@ -318,30 +318,10 @@ circ.copy_status.prototype = {
                                                ['command'],
                                                function() {
                                                        try {
-                                                               obj.list.on_all_fleshed =
-                                                                       function() {
-                                                                               try {
-                                                                                       dump( js2JSON( obj.list.dump_with_keys() ) + '\n' );
-                                                                                       obj.data.stash_retrieve();
-                                                                                       var lib = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
-                                                                                       lib.children(null);
-                                                                                       var p = { 
-                                                                                               'lib' : lib,
-                                                                                               'staff' : obj.data.list.au[0],
-                                                                                               'header' : obj.data.print_list_templates.item_status.header,
-                                                                                               'line_item' : obj.data.print_list_templates.item_status.line_item,
-                                                                                               'footer' : obj.data.print_list_templates.item_status.footer,
-                                                                                               'type' : obj.data.print_list_templates.item_status.type,
-                                                                                               'list' : obj.list.dump_with_keys(),
-                                                                                       };
-                                                                                       JSAN.use('util.print'); var print = new util.print();
-                                                                                       print.tree_list( p );
-                                                                                       setTimeout(function(){ obj.list.on_all_fleshed = null; },0);
-                                                                               } catch(E) {
-                                                                                       obj.error.standard_unexpected_error_alert('print',E); 
-                                                                               }
-                                                                       }
-                                                               obj.list.full_retrieve();
+                                var p = { 
+                                    'template' : 'item_status'
+                                };
+                                                               obj.list.print(p);
                                                        } catch(E) {
                                                                obj.error.standard_unexpected_error_alert('print',E); 
                                                        }
@@ -351,17 +331,7 @@ circ.copy_status.prototype = {
                                                ['command'],
                                                function() {
                                                        try {
-                                                               obj.list.on_all_fleshed =
-                                                                       function() {
-                                                                               try {
-                                                                                       dump( obj.list.dump_csv() + '\n' );
-                                                                                       copy_to_clipboard(obj.list.dump_csv());
-                                                                                       setTimeout(function(){ obj.list.on_all_fleshed = null; },0);
-                                                                               } catch(E) {
-                                                                                       obj.error.standard_unexpected_error_alert('export',E); 
-                                                                               }
-                                                                       }
-                                                               obj.list.full_retrieve();
+                                                               obj.list.dump_csv_to_clipboard();
                                                        } catch(E) {
                                                                obj.error.standard_unexpected_error_alert('export',E); 
                                                        }
index 22b1eaf..cc544a0 100644 (file)
@@ -60,29 +60,10 @@ circ.hold_capture.prototype = {
                                        'cmd_hold_capture_print' : [
                                                ['command'],
                                                function() {
-                                                       obj.list.on_all_fleshed = function() {
-                                                               try {
-                                                                       dump( js2JSON( obj.list.dump_with_keys() ) + '\n' );
-                                                                       obj.OpenILS.data.stash_retrieve();
-                                                                       var lib = obj.OpenILS.data.hash.aou[ obj.OpenILS.data.list.au[0].ws_ou() ];
-                                                                       lib.children(null);
-                                                                       var p = { 
-                                                                               'lib' : lib,
-                                                                               'staff' : obj.OpenILS.data.list.au[0],
-                                                                               'header' : obj.OpenILS.data.print_list_templates.hold_capture.header,
-                                                                               'line_item' : obj.OpenILS.data.print_list_templates.hold_capture.line_item,
-                                                                               'footer' : obj.OpenILS.data.print_list_templates.hold_capture.footer,
-                                                                               'type' : obj.OpenILS.data.print_list_templates.hold_capture.type,
-                                                                               'list' : obj.list.dump_with_keys(),
-                                                                       };
-                                                                       JSAN.use('util.print'); var print = new util.print();
-                                                                       print.tree_list( p );
-                                                                       setTimeout(function(){obj.list.on_all_fleshed = null;},0);
-                                                               } catch(E) {
-                                                                       alert(E); 
-                                                               }
-                                                       }
-                                                       obj.list.full_retrieve();
+                                                       var p = { 
+                                                               'template' : 'hold_capture'
+                                                       };
+                                                       obj.list.print(p);
                                                }
                                        ],
                                        'cmd_hold_capture_reprint' : [
index 763888b..9c2d24e 100644 (file)
@@ -155,44 +155,16 @@ circ.in_house_use.prototype = {
                                        'cmd_in_house_use_print' : [
                                                ['command'],
                                                function() {
-                                                       obj.list.on_all_fleshed = function() {
-                                                               try {
-                                                                       dump( js2JSON( obj.list.dump_with_keys() ) + '\n' );
-                                                                       obj.data.stash_retrieve();
-                                                                       var lib = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
-                                                                       lib.children(null);
-                                                                       var p = { 
-                                                                               'lib' : lib,
-                                                                               'staff' : obj.data.list.au[0],
-                                                                               'header' : obj.data.print_list_templates.in_house_use.header,
-                                                                               'line_item' : obj.data.print_list_templates.in_house_use.line_item,
-                                                                               'footer' : obj.data.print_list_templates.in_house_use.footer,
-                                                                               'type' : obj.data.print_list_templates.in_house_use.type,
-                                                                               'list' : obj.list.dump_with_keys(),
-                                                                       };
-                                                                       JSAN.use('util.print'); var print = new util.print();
-                                                                       print.tree_list( p );
-                                                                       setTimeout(function(){obj.list.on_all_fleshed = null;},0);
-                                                               } catch(E) {
-                                                                       alert(E); 
-                                                               }
-                                                       }
-                                                       obj.list.full_retrieve();
+                                                       var p = { 
+                                                               'template' : 'in_house_use'
+                                                       };
+                                                       obj.list.print(p);
                                                }
                                        ],
                                        'cmd_in_house_use_export' : [
                                                ['command'],
                                                function() {
-                                                       obj.list.on_all_fleshed = function() {
-                                                               try {
-                                                                       dump(obj.list.dump_csv() + '\n');
-                                                                       copy_to_clipboard(obj.list.dump_csv());
-                                                                       setTimeout(function(){obj.list.on_all_fleshed = null;},0);
-                                                               } catch(E) {
-                                                                       alert(E); 
-                                                               }
-                                                       }
-                                                       obj.list.full_retrieve();
+                                                       obj.list.dump_csv_to_clipboard();
                                                }
                                        ],
 
index eaf4974..f4d9763 100644 (file)
 
                function print_bills() {
                        try {
-                               g.bill_list.on_all_fleshed = function() {
-                                       try {
-                                               var template = 'bills_historical'; if (xul_param('current')) template = 'bills_current';
-                                               JSAN.use('patron.util');
-                                               var params = { 
-                                                       'patron' : patron.util.retrieve_au_via_id(ses(),g.patron_id), 
-                                                       'lib' : g.data.hash.aou[ g.data.list.au[0].ws_ou() ],
-                                                       'staff' : g.data.list.au[0],
-                                                       'header' : g.data.print_list_templates[template].header,
-                                                       'line_item' : g.data.print_list_templates[template].line_item,
-                                                       'footer' : g.data.print_list_templates[template].footer,
-                                                       'type' : g.data.print_list_templates[template].type,
-                                                       'list' : g.bill_list.dump_with_keys(),
-                                                       //'modal' : true,
-                                               };
-                                               JSAN.use('util.print'); var print = new util.print();
-                                               print.tree_list( params );
-                                               setTimeout(function(){ g.bill_list.on_all_fleshed = null; },0);
-                                       } catch(E) {
-                                               g.error.standard_unexpected_error_alert('printing bills', E);
-                                       }
-                               }
-                               g.bill_list.full_retrieve();
+                var template = 'bills_historical'; if (xul_param('current')) template = 'bills_current';
+                JSAN.use('patron.util');
+                var params = { 
+                    'patron' : patron.util.retrieve_au_via_id(ses(),g.patron_id), 
+                    'template' : template
+                };
+                               g.bill_list.print(params);
                        } catch(E) {
                                g.error.standard_unexpected_error_alert('printing bills', E);
                        }
index ada1d77..cbf1072 100644 (file)
@@ -311,29 +311,12 @@ patron.holds.prototype = {
                                                ['command'],
                                                function() {
                                                        try {
-                                                               dump(js2JSON(obj.list.dump_with_keys()) + '\n');
-                                                               function flesh_callback() {
-                                                                       try {
-                                                                               JSAN.use('patron.util');
-                                                                               var params = { 
-                                                                                       'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id), 
-                                                                                       'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ],
-                                                                                       'staff' : obj.data.list.au[0],
-                                                                                       'header' : obj.data.print_list_templates.holds.header,
-                                                                                       'line_item' : obj.data.print_list_templates.holds.line_item,
-                                                                                       'footer' : obj.data.print_list_templates.holds.footer,
-                                                                                       'type' : obj.data.print_list_templates.holds.type,
-                                                                                       'list' : obj.list.dump_with_keys(),
-                                                                               };
-                                                                               JSAN.use('util.print'); var print = new util.print();
-                                                                               print.tree_list( params );
-                                                                               setTimeout(function(){obj.list.on_all_fleshed = null;},0);
-                                                                       } catch(E) {
-                                                                               obj.error.standard_unexpected_error_alert('print 2',E);
-                                                                       }
-                                                               }
-                                                               obj.list.on_all_fleshed = flesh_callback;
-                                                               obj.list.full_retrieve();
+                                                               JSAN.use('patron.util');
+                                                               var params = { 
+                                                                       'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id), 
+                                                                       'template' : 'holds'
+                                                               };
+                                                               obj.list.print(params);
                                                        } catch(E) {
                                                                obj.error.standard_unexpected_error_alert('print 1',E);
                                                        }
@@ -343,17 +326,7 @@ patron.holds.prototype = {
                                                ['command'],
                                                function() {
                                                        try {
-                                                               function flesh_callback() {
-                                                                       try {
-                                                                               dump(obj.list.dump_csv() + '\n');
-                                                                               copy_to_clipboard(obj.list.dump_csv());
-                                                                               setTimeout(function(){obj.list.on_all_fleshed = null;},0);
-                                                                       } catch(E) {
-                                                                               obj.error.standard_unexpected_error_alert('export 2',E);
-                                                                       }
-                                                               }
-                                                               obj.list.on_all_fleshed = flesh_callback;
-                                                               obj.list.full_retrieve();
+                                                               obj.list.dump_csv_to_clipboard();
                                                        } catch(E) {
                                                                obj.error.standard_unexpected_error_alert('export 1',E);
                                                        }
index 6e8da28..deef6ec 100644 (file)
@@ -200,29 +200,12 @@ patron.items.prototype = {
                var obj = this;
                try {
                        var list = (which==2 ? obj.list2 : obj.list);
-                       dump(js2JSON( list.dump_with_keys() ) + '\n');
-                       function flesh_callback() {
-                               try {
-                                       JSAN.use('patron.util');
-                                       var params = { 
-                                               'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id), 
-                                               'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ],
-                                               'staff' : obj.data.list.au[0],
-                                               'header' : obj.data.print_list_templates.items_out.header,
-                                               'line_item' : obj.data.print_list_templates.items_out.line_item,
-                                               'footer' : obj.data.print_list_templates.items_out.footer,
-                                               'type' : obj.data.print_list_templates.items_out.type,
-                                               'list' : list.dump_with_keys(),
-                                       };
-                                       JSAN.use('util.print'); var print = new util.print();
-                                       print.tree_list( params );
-                                       setTimeout(function(){list.on_all_fleshed = null;},0);
-                               } catch(E) {
-                                       obj.error.standard_unexpected_error_alert('printing 2',E);
-                               }
-                       }
-                       list.on_all_fleshed = flesh_callback;
-                       list.full_retrieve();
+            JSAN.use('patron.util');
+            var params = { 
+                'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id), 
+                'template' : 'items_out'
+            };
+            list.print( params );
                } catch(E) {
                        obj.error.standard_unexpected_error_alert('printing 1',E);
                }
@@ -232,17 +215,7 @@ patron.items.prototype = {
                var obj = this;
                try {
                        var list = (which==2 ? obj.list2 : obj.list);
-                       function flesh_callback() {
-                               try {
-                                       dump( list.dump_csv() + '\n');
-                                       copy_to_clipboard(list.dump_csv());
-                                       setTimeout(function(){list.on_all_fleshed = null;},0);
-                               } catch(E) {
-                                       obj.error.standard_unexpected_error_alert('export 2',E);
-                               }
-                       }
-                       list.on_all_fleshed = flesh_callback;
-                       list.full_retrieve();
+                       list.dump_csv_to_clipboard();
                } catch(E) {
                        obj.error.standard_unexpected_error_alert('export 1',E);
                }
index 1e1ee51..ff472ea 100644 (file)
@@ -94,32 +94,14 @@ patron.search_result.prototype = {
                                        'cmd_search_print' : [
                                                ['command'],
                                                function() {
-                                                       dump( js2JSON( obj.list.dump_with_keys() ) );
-                                                       JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
-                                                       obj.list.on_all_fleshed = function() {
-                                                               try {
-                                                                       dump( js2JSON( obj.list.dump_with_keys() ) + '\n' );
-                                                                       obj.OpenILS.data.stash_retrieve();
-                                                                       var lib = data.hash.aou[ data.list.au[0].ws_ou() ];
-                                                                       lib.children(null);
-                                                                       var p = { 
-                                                                               'lib' : lib,
-                                                                               'staff' : data.list.au[0],
-                                                                               'header' : data.print_list_templates.patron.header,
-                                                                               'line_item' : data.print_list_templates.patron.line_item,
-                                                                               'footer' : data.print_list_templates.patron.footer,
-                                                                               'type' : data.print_list_templates.patron.type,
-                                                                               'list' : obj.list.dump_with_keys(),
-                                                                       };
-                                                                       JSAN.use('util.print'); var print = new util.print();
-                                                                       print.tree_list( p );
-                                                                       setTimeout(function(){obj.list.on_all_fleshed = null;},0);
-                                                               } catch(E) {
-                                                                       alert(E); 
-                                                               }
-                                                       }
-                                                       obj.list.full_retrieve();
-
+                            try {
+                                                               var p = { 
+                                                                       'template' : 'patron'
+                                                               };
+                                                               obj.list.print( p );
+                            } catch(E) {
+                                                               obj.error.standard_unexpected_error_alert('patron search print',E);
+                            }
                                                }
                                        ],
                                        'cmd_sel_clip' : [