export csv from list to clipboard
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Oct 2006 20:32:00 +0000 (20:32 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 23 Oct 2006 20:32:00 +0000 (20:32 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6501 dcc99617-32d9-48b4-a31d-7c20da2025e4

26 files changed:
Open-ILS/xul/staff_client/chrome/content/util/list.js
Open-ILS/xul/staff_client/server/cat/copy_buckets.js
Open-ILS/xul/staff_client/server/cat/copy_buckets.xul
Open-ILS/xul/staff_client/server/cat/copy_buckets_overlay.xul
Open-ILS/xul/staff_client/server/cat/record_buckets.js
Open-ILS/xul/staff_client/server/cat/record_buckets.xul
Open-ILS/xul/staff_client/server/cat/record_buckets_overlay.xul
Open-ILS/xul/staff_client/server/cat/z3950.js
Open-ILS/xul/staff_client/server/cat/z3950.xul
Open-ILS/xul/staff_client/server/circ/checkin.js
Open-ILS/xul/staff_client/server/circ/checkin.xul
Open-ILS/xul/staff_client/server/circ/checkin_overlay.xul
Open-ILS/xul/staff_client/server/circ/checkout.js
Open-ILS/xul/staff_client/server/circ/checkout.xul
Open-ILS/xul/staff_client/server/circ/checkout_overlay.xul
Open-ILS/xul/staff_client/server/circ/copy_status.js
Open-ILS/xul/staff_client/server/circ/copy_status.xul
Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul
Open-ILS/xul/staff_client/server/circ/in_house_use.js
Open-ILS/xul/staff_client/server/circ/in_house_use.xul
Open-ILS/xul/staff_client/server/patron/holds.js
Open-ILS/xul/staff_client/server/patron/holds.xul
Open-ILS/xul/staff_client/server/patron/holds_overlay.xul
Open-ILS/xul/staff_client/server/patron/items.js
Open-ILS/xul/staff_client/server/patron/items.xul
Open-ILS/xul/staff_client/server/patron/items_overlay.xul

index fc2650c..815c9de 100644 (file)
@@ -813,6 +813,44 @@ util.list.prototype = {
                return dump;
        },
 
+       'dump_csv' : function(params) {
+               var obj = this;
+               switch(this.node.nodeName) {
+                       case 'tree' : return this._dump_tree_csv(params); break;
+                       default: throw('NYI: Need .dump_csv() for ' + this.node.nodeName); break;
+               }
+
+       },
+
+       '_dump_tree_csv' : function(params) {
+               var obj = this;
+               var dump = '';
+               for (var j = 0; j < obj.columns.length; j++) {
+                       if (obj.columns[j].hidden) {
+                               /* skip */
+                       } else {
+                               if (dump) dump += ',';
+                               dump += '"' + obj.columns[j].label.replace(/"/g, '""') + '"';
+                       }
+               }
+               dump += '\r\n';
+               for (var i = 0; i < this.treechildren.childNodes.length; i++) {
+                       var row = '';
+                       var treeitem = this.treechildren.childNodes[i];
+                       var treerow = treeitem.firstChild;
+                       for (var j = 0; j < treerow.childNodes.length; j++) {
+                               if (obj.columns[j].hidden) {
+                                       /* skip */
+                               } else {
+                                       if (row) row += ',';
+                                       row += '"' + treerow.childNodes[j].getAttribute('label').replace(/"/g, '""') + '"';
+                               }
+                       }
+                       dump +=  row + '\r\n';
+               }
+               return dump;
+       },
+
        'dump_selected_with_keys' : function(params) {
                var obj = this;
                switch(this.node.nodeName) {
index d850a74..feab5e8 100644 (file)
@@ -532,6 +532,22 @@ cat.copy_buckets.prototype = {
                                                        obj.list2.full_retrieve();
                                                }
                                        ],
+                                       '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();
+                                               }
+                                       ],
+
                                        'cmd_copy_buckets_reprint' : [
                                                ['command'],
                                                function() {
index d24e45a..8dc6fb9 100644 (file)
@@ -79,6 +79,7 @@
                <command id="sel_clip" />
                <command id="cmd_copy_buckets_submit_barcode" />
                <command id="cmd_copy_buckets_print" />
+               <command id="cmd_copy_buckets_export" />
                <command id="cmd_copy_buckets_reprint" />
                <command id="cmd_copy_buckets_done" />
                <command id="cmd_export_to_copy_status" />
index 64b6c3c..dc8b9fb 100644 (file)
 
 <hbox id="copy_buckets_bottom_ui">
        <button id="copy_buckets_print" label="Print" command="cmd_copy_buckets_print" accesskey="P"/>
+       <button id="copy_buckets_export" 
+               label="Export"
+               command="cmd_copy_buckets_export"
+               accesskey=""/>
        <spacer flex="1"/>
        <hbox style="background: grey">
                <vbox><spacer flex="1"/><label value="Batch:" style="font-weight: bold"/><spacer flex="1"/></vbox>
index 87493ec..d647d22 100644 (file)
@@ -361,6 +361,23 @@ 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();
+                                               }
+                                       ],
+
                                        'cmd_merge_records' : [
                                                ['command'],
                                                function() {
index c11003b..d1c40ce 100644 (file)
@@ -84,6 +84,7 @@
                <command id="sel_clip" />
                <command id="cmd_record_buckets_submit_barcode" />
                <command id="cmd_record_buckets_print" />
+               <command id="cmd_record_buckets_export" />
                <command id="cmd_record_buckets_reprint" />
                <command id="cmd_record_buckets_done" />
                <command id="cmd_merge_records" />
index cc61a52..47ad6da 100644 (file)
 </hbox>
 
 <hbox id="record_buckets_bottom_ui">
+       <button id="record_buckets_export" 
+               label="Export"
+               command="cmd_record_buckets_export"
+               accesskey=""/>
        <spacer flex="1"/>
        <hbox style="background: grey">
                <vbox><spacer flex="1"/><label value="Batch:" style="font-weight: bold"/><spacer flex="1"/></vbox>
index 15a2d4a..584ab1b 100644 (file)
@@ -75,6 +75,21 @@ cat.z3950.prototype = {
                                                        ['command'],
                                                        function() { obj.list.clipboard(); }
                                                ],
+                                               '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) {
+                                                                               alert(E); 
+                                                                       }
+                                                               }
+                                                               obj.list.full_retrieve();
+                                                       }
+                                               ],
                                                'cmd_broken' : [
                                                        ['command'],
                                                        function() { alert('Not Yet Implemented'); }
index 32253a4..3aefdfb 100644 (file)
@@ -79,6 +79,7 @@
 
        <commandset id="cat_z3950_cmds">
                <command id="cmd_broken" />
+               <command id="cmd_export" />
                <command id="sel_clip" />
                <command id="save_columns" />
        </commandset>
                        <vbox id="result_message" />
                        <hbox>
                                <button id="page_next" label="Fetch More Results" accesskey="M" disabled="true"/>
+                               <button id="export" label="Export" command="cmd_export" accesskey=""/>
                                <button id="clip_button" command="sel_clip" label="Copy to Clipboard" disabled="true"/>
                                <button id="save_cols_btn" command="save_columns" label="Save Columns" />
                                <spacer flex="1"/>
index 6cc903a..3482f03 100644 (file)
@@ -242,6 +242,22 @@ circ.checkin.prototype = {
                                                        obj.list.full_retrieve();
                                                }
                                        ],
+                                       '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();
+                                               }
+                                       ],
+
                                        'cmd_checkin_reprint' : [
                                                ['command'],
                                                function() {
index ee0e102..741369d 100644 (file)
@@ -81,6 +81,7 @@
        <commandset id="checkin_cmds">
                <command id="cmd_checkin_submit_barcode" />
                <command id="cmd_checkin_print" />
+               <command id="cmd_checkin_export" />
                <command id="cmd_checkin_reprint" />
                <command id="cmd_checkin_done" />
                <command id="save_columns" />
index a8dbe31..ea6eb91 100644 (file)
                label="&staff.checkin.print_receipt_label;" 
                command="cmd_checkin_print"
                accesskey="&staff.checkin.print_receipt_label.accesskey;"/>
+       <button id="checkin_export" 
+               label="Export"
+               command="cmd_checkin_export"
+               accesskey=""/>
        <checkbox id="trim_list" label="Trim List (20 rows)" checked="true" persist="checked"/> 
        <checkbox id="do_not_alert_on_precat" label="Don't Alert on Pre-Cat" persist="checked"/> 
        <spacer id="pcii3s" flex="1"/>
index 2087418..b022a44 100644 (file)
@@ -185,6 +185,18 @@ circ.checkout.prototype = {
 
                                                }
                                        ],
+                                       'cmd_checkout_export' : [
+                                               ['command'],
+                                               function() {
+                                                       try {
+                                                               obj.export_list();
+                                                       } catch(E) {
+                                                               obj.error.standard_unexpected_error_alert('cmd_checkout_export',E); 
+                                                       }
+                                               }
+                                       ],
+
+
                                        'cmd_checkout_reprint' : [
                                                ['command'],
                                                function() {
@@ -280,6 +292,24 @@ circ.checkout.prototype = {
                        obj.error.standard_unexpected_error_alert('print',E);
                }
        },
+       
+       '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();
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('export',E);
+               }
+       },
 
        'check_date' : function(node) {
                JSAN.use('util.date');
index ffe9d58..a57f4b9 100644 (file)
@@ -86,6 +86,7 @@
        <commandset id="checkout_cmds">
                <command id="cmd_checkout_submit" />
                <command id="cmd_checkout_print" />
+               <command id="cmd_checkout_export" />
                <command id="cmd_checkout_reprint" />
                <command id="cmd_checkout_done" />
                <command id="sel_clip" />
index e23a283..46406b2 100644 (file)
                label="&staff.patron_display.checkout.print_receipt_label;" 
                command="cmd_checkout_print"
                accesskey="&staff.patron_display.checkout.print_receipt_label.accesskey;"/>
-       <button id="checkout_reprint" 
-               label="&staff.patron_display.checkout.reprint_receipt_label;" 
-               command="cmd_checkout_reprint"
-               accesskey="&staff.patron_display.checkout.reprint_receipt_label.accesskey;"/>
+       <button id="checkout_export" 
+               label="Export"
+               command="cmd_checkout_export"
+               accesskey=""/>
        <button id="clip_button" disabled="true" command="sel_clip" label="Copy to Clipboard" />
        <button id="save_col_btn" command="save_columns" label="Save Columns" />
        <spacer id="pcii3s" flex="1"/>
index 4e05a6d..be642f9 100644 (file)
@@ -298,6 +298,27 @@ circ.copy_status.prototype = {
                                                        }
                                                }
                                        ],
+                                       'cmd_copy_status_export' : [
+                                               ['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();
+                                                       } catch(E) {
+                                                               obj.error.standard_unexpected_error_alert('export',E); 
+                                                       }
+                                               }
+                                       ],
+
                                        'cmd_copy_status_reprint' : [
                                                ['command'],
                                                function() {
index 48d1c4b..ba6acc7 100644 (file)
@@ -85,6 +85,7 @@
        <commandset id="copy_status_cmds">
                <command id="cmd_copy_status_submit_barcode" />
                <command id="cmd_copy_status_print" />
+               <command id="cmd_copy_status_export" />
                <command id="cmd_copy_status_reprint" />
                <command id="cmd_copy_status_done" />
                <command id="save_columns" />
index 9f3d9e8..5a8b186 100644 (file)
                label="Print"
                command="cmd_copy_status_print"
                accesskey="P"/>
+       <button id="copy_status_export" 
+               label="Export"
+               command="cmd_copy_status_export"
+               accesskey=""/>
        <checkbox id="trim_list" label="Trim List (20 rows)" checked="true" persist="checked"/> 
        <spacer flex="1"/>
 </hbox>
index 0589aa3..435ab23 100644 (file)
@@ -180,6 +180,22 @@ circ.in_house_use.prototype = {
                                                        obj.list.full_retrieve();
                                                }
                                        ],
+                                       '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();
+                                               }
+                                       ],
+
                                        'cmd_in_house_use_reprint' : [
                                                ['command'],
                                                function() {
index e5f5ef9..710eeee 100644 (file)
@@ -69,6 +69,7 @@
                <command id="sel_clip" />
                <command id="cmd_in_house_use_submit_barcode" />
                <command id="cmd_in_house_use_print" />
+               <command id="cmd_in_house_use_export" />
                <command id="cmd_in_house_use_reprint" />
                <command id="cmd_in_house_use_done" />
                <command id="save_columns" />
                        label="Print List" 
                        command="cmd_in_house_use_print"
                        accesskey=""/>
+               <button id="in_house_use_export" 
+                       label="Export"
+                       command="cmd_in_house_use_export"
+                       accesskey=""/>
                <checkbox id="trim_list" label="Trim List (20 rows)" checked="true" persist="checked"/> 
                <spacer id="pcii3s" flex="1"/>
                <button id="clip_button" disabled="true" command="sel_clip" label="Copy to Clipboard" />
index 2d36764..a5724df 100644 (file)
@@ -323,6 +323,27 @@ patron.holds.prototype = {
                                                        }
                                                }
                                        ],
+                                       'cmd_holds_export' : [
+                                               ['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();
+                                                       } catch(E) {
+                                                               obj.error.standard_unexpected_error_alert('export 1',E);
+                                                       }
+                                               }
+                                       ],
+
                                        'cmd_show_notifications' : [
                                                ['command'],
                                                function() {
index 7603e8a..efd91fe 100644 (file)
@@ -76,6 +76,7 @@
                <command id="sel_patron" disabled="true"/>
                <command id="sel_clip" />
                <command id="cmd_holds_print" />
+               <command id="cmd_holds_export" />
                <command id="cmd_show_catalog" />
                <command id="cmd_retrieve_patron" />
                <command id="cmd_show_notifications" />
index a13ca12..fb248d2 100644 (file)
 <hbox id="holds_bottom_ui" flex="1">
        <spacer flex="1"/>
        <button id="holds_print" label="Print" command="cmd_holds_print" accesskey="P" />
+       <button id="holds_export" 
+               label="Export"
+               command="cmd_holds_export"
+               accesskey=""/>
 </hbox>
 
 </overlay>
index c30154f..e05d296 100644 (file)
@@ -71,6 +71,8 @@ patron.items.prototype = {
                                        ],
                                        'cmd_items_print' : [ ['command'], function() { obj.items_print(1); } ],
                                        'cmd_items_print2' : [ ['command'], function() { obj.items_print(2); } ],
+                                       'cmd_items_export' : [ ['command'], function() { obj.items_export(1); } ],
+                                       'cmd_items_export2' : [ ['command'], function() { obj.items_export(2); } ],
                                        'cmd_items_renew' : [ ['command'], function() { obj.items_renew(1); alert('Action complete.'); obj.retrieve(); } ],
                                        'cmd_items_renew_all' : [ ['command'], function() { obj.items_renew_all(); } ],
                                        'cmd_items_renew2' : [ ['command'], function() { obj.items_renew(2); alert('Action complete.'); obj.retrieve(); } ],
@@ -208,6 +210,26 @@ patron.items.prototype = {
                }
        },
 
+       'items_export' : function(which) {
+               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();
+               } catch(E) {
+                       obj.error.standard_unexpected_error_alert('export 1',E);
+               }
+       },
+
        'items_renew_all' : function() {
                try {
                        var obj = this; var list = obj.list;
index 7d66ba5..8366dc1 100644 (file)
@@ -73,6 +73,7 @@
                <command id="sel_copy_details"/>
                <command id="sel_patron"/>
                <command id="cmd_items_print" />
+               <command id="cmd_items_export" />
                <command id="cmd_items_renew" />
                <command id="cmd_items_renew_all" />
                <command id="cmd_items_claimed_returned" />
@@ -91,6 +92,7 @@
                <command id="sel_copy_details2"/>
                <command id="sel_patron2"/>
                <command id="cmd_items_print2" />
+               <command id="cmd_items_export2" />
                <command id="cmd_items_renew2" />
                <command id="cmd_items_claimed_returned2" />
                <command id="cmd_items_checkin2" />
index bdc302f..338f317 100644 (file)
        <button id="noncat" label="Show Non-Cataloged Circulations in List Above" command="cmd_show_noncats" accesskey="N"/>
        <spacer flex="1"/>
        <button id="items_print" label="&staff.patron_display.items.print_receipt_label;" command="cmd_items_print" accesskey="&staff.patron_display.items.print_receipt_label.accesskey;" />
+       <button id="items_export" 
+               label="Export"
+               command="cmd_items_export"
+               accesskey=""/>
 </hbox>
 
 <hbox id="items_bottom_ui2" flex="1">
        <spacer flex="1"/>
        <button id="items_print2" label="&staff.patron_display.items.print_receipt_label;" command="cmd_items_print2" old_accesskey="&staff.patron_display.items.print_receipt_label.accesskey;" />
+       <button id="items_export2" 
+               label="Export"
+               command="cmd_items_export2"
+               accesskey=""/>
 </hbox>
 
 </overlay>