From 2181ca8abede9f674c5dbd3902be3d70308a75d2 Mon Sep 17 00:00:00 2001 From: phasefx Date: Sat, 14 Nov 2009 08:36:57 +0000 Subject: [PATCH] List Actions -> Print List Expanded Format Similar to Print List CSV in that in prints visible columns without using a template, but it pivots the data vertically, similar to the \x option in psql. So instead of getting something like: "Alert Message"\t"Barcode"\r\n "3 dvd's"\t"b1"\r\n "2 cassettes"\t"b2"\r\n You'll instead get: =-=-= Alert Message: 3 dvd's Barcode: b1 =-=-= Alert Message: 2 cassettes Barcode: b2 git-svn-id: svn://svn.open-ils.org/ILS/trunk@14915 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/chrome/content/util/list.js | 62 ++++++++++++++++++++++ .../chrome/locale/en-US/offline.properties | 3 ++ 2 files changed, 65 insertions(+) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js index e18e69340a..88bb6ec126 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -1150,6 +1150,34 @@ util.list.prototype = { return dump; }, + 'dump_extended_format' : function(params) { + var obj = this; + switch(this.node.nodeName) { + case 'tree' : return this._dump_tree_extended_format(params); break; + default: throw('NYI: Need .dump_extended_format() for ' + this.node.nodeName); break; + } + + }, + + '_dump_tree_extended_format' : function(params) { + var obj = this; + var dump = ''; + for (var i = 0; i < this.treechildren.childNodes.length; i++) { + var row = document.getElementById('offlineStrings').getString('list.dump_extended_format.record_separator') + '\r\n'; + var treeitem = this.treechildren.childNodes[i]; + var treerow = treeitem.firstChild; + for (var j = 0; j < treerow.childNodes.length; j++) { + if (obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('hidden') == 'true') { + /* skip */ + } else { + row += obj.columns[j].label + ': ' + treerow.childNodes[j].getAttribute('label') + '\r\n'; + } + } + dump += row + '\r\n'; + } + return dump; + }, + 'dump_csv_to_clipboard' : function(params) { var obj = this; if (typeof params == 'undefined') params = {}; @@ -1175,6 +1203,21 @@ util.list.prototype = { } }, + 'dump_extended_format_to_printer' : function(params) { + var obj = this; + JSAN.use('util.print'); var print = new util.print(); + if (typeof params == 'undefined') params = {}; + if (params.no_full_retrieve) { + print.simple( obj.dump_extended_format( params ), {'content_type':'text/plain'} ); + } else { + obj.wrap_in_full_retrieve( + function() { + print.simple( obj.dump_extended_format( params ), {'content_type':'text/plain'} ); + } + ); + } + }, + 'dump_csv_to_file' : function(params) { var obj = this; JSAN.use('util.file'); var f = new util.file(); @@ -1436,6 +1479,11 @@ util.list.prototype = { mi.setAttribute('accesskey',document.getElementById('offlineStrings').getString('list.actions.csv_to_printer.accesskey')); mp.appendChild(mi); mi = document.createElement('menuitem'); + mi.setAttribute('id',obj.node.id + '_extended_to_printer'); + mi.setAttribute('label',document.getElementById('offlineStrings').getString('list.actions.extended_to_printer.label')); + mi.setAttribute('accesskey',document.getElementById('offlineStrings').getString('list.actions.extended_to_printer.accesskey')); + mp.appendChild(mi); + mi = document.createElement('menuitem'); mi.setAttribute('id',obj.node.id + '_csv_to_file'); mi.setAttribute('label',document.getElementById('offlineStrings').getString('list.actions.csv_to_file.label')); mi.setAttribute('accesskey',document.getElementById('offlineStrings').getString('list.actions.csv_to_file.accesskey')); @@ -1502,6 +1550,20 @@ util.list.prototype = { false ); } + x = document.getElementById(obj.node.id + '_extended_to_printer'); + if (x) { + x.addEventListener( + 'command', + function() { + obj.dump_extended_format_to_printer(params); + if (params && typeof params.on_complete == 'function') { + params.on_complete(params); + } + }, + false + ); + } + x = document.getElementById(obj.node.id + '_csv_to_file'); if (x) { x.addEventListener( diff --git a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties index 04836aaafc..da4aa785e6 100644 --- a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties +++ b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties @@ -203,10 +203,13 @@ list.actions.csv_to_clipboard.label=Copy List CSV to Clipboard list.actions.csv_to_clipboard.accesskey=L list.actions.csv_to_printer.label=Print List CSV list.actions.csv_to_printer.accesskey=P +list.actions.extended_to_printer.label=Print List Expanded Format +list.actions.extended_to_printer.accesskey=x list.actions.csv_to_file.label=Save List CSV to File list.actions.csv_to_file.accesskey=F list.actions.save_column_configuration.label=Save Column Configuration list.actions.save_column_configuration.accesskey=S +list.dump_extended_format.record_separator==-=-= menu.cmd_survey_wizard.inadequate_perm=You are lacking the CREATE_SURVEY permission and/or working locations. menu.cmd_local_admin_fonts_and_sounds.tab=Global Font and Sound Settings menu.cmd_local_admin_printer.tab=Printer Settings Editor -- 2.11.0