Author: nathangray
Date: Thu Apr 21 01:05:43 2016
New Revision: 55792
URL: http://svn.stylite.de/viewvc/egroupware?rev=55792&view=rev
Log:
Prompt for columns to print as well as row count when printing a nextmatch
Added:
trunk/egroupware/api/templates/default/nm_print_dialog.xet
Modified:
trunk/egroupware/api/js/etemplate/et2_extension_nextmatch.js
Modified: trunk/egroupware/api/js/etemplate/et2_extension_nextmatch.js
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/js/etemplate/et2_extension_nextmatch.js?rev=55792&r1=55791&r2=55792&view=diff
==============================================================================
--- trunk/egroupware/api/js/etemplate/et2_extension_nextmatch.js (original)
+++ trunk/egroupware/api/js/etemplate/et2_extension_nextmatch.js Thu Apr 21 01:05:43 2016
@@ -2023,139 +2023,186 @@
this.old_height = this.controller._grid._scrollHeight;
var loaded_count = range.bottom - range.top +1;
var total = this.controller._grid.getTotalCount();
- if(loaded_count != total ||
- this.controller._grid.getTotalCount() > 100)
- {
- // Defer the printing
- var defer = jQuery.Deferred();
-
- // Something not in the grid, lets ask
- et2_dialog.show_prompt(jQuery.proxy(function(button, value) {
- if(button == 'dialog[cancel]') {
- // Give dialog a chance to close, or it will be in the print
- window.setTimeout(function() {defer.reject();}, 0);
- return;
+
+ // Defer the printing to ask about columns & rows
+ var defer = jQuery.Deferred();
+
+
+ var pref = this.options.settings.columnselection_pref;
+ var app = this.getInstanceManager().app;
+
+ var columns = {};
+ var columnMgr = this.dataview.getColumnMgr();
+ pref += '_print';
+ var columns_selected = [];
+
+ // Get column names
+ for (var i = 0; i < columnMgr.columns.length; i++)
+ {
+ var col = columnMgr.columns[i];
+ var widget = this.columns[i].widget;
+ var colName = this._getColumnName(widget);
+
+ if(col.caption && col.visibility !== ET2_COL_VISIBILITY_ALWAYS_NOSELECT &&
+ col.visibility !== ET2_COL_VISIBILITY_DISABLED)
+ {
+ columns[colName] = col.caption;
+ if(col.visibility === ET2_COL_VISIBILITY_VISIBLE) columns_selected.push(colName);
+ }
+ // Custom fields get listed separately
+ if(widget.instanceOf(et2_nextmatch_customfields))
+ {
+ if(jQuery.isEmptyObject(widget.customfields))
+ {
+ // No customfields defined, don't show column
+ delete(columns[col.id]);
+ continue;
+ }
+ for(var field_name in widget.customfields)
+ {
+ columns[widget.prefix+field_name] = " - "+widget.customfields[field_name].label;
+ if(widget.options.fields[field_name]) columns_selected.push(et2_customfields_list.prototype.prefix+field_name);
+ }
+ }
+ }
+
+ // Preference exists? Set it now
+ if(this.egw().preference(pref,app))
+ {
+ this.set_columns(jQuery.extend([],this.egw().preference(pref,app)));
+ }
+
+ var callback = jQuery.proxy(function(button, value) {
+ if(button === et2_dialog.CANCEL_BUTTON) {
+ // Give dialog a chance to close, or it will be in the print
+ window.setTimeout(function() {defer.reject();}, 0);
+ return;
+ }
+
+ // Handle columns
+ this.set_columns(value.columns);
+ this.egw().set_preference(app,pref,value.columns);
+
+ var rows = parseInt(value.row_count);
+ if(rows > total)
+ {
+ rows = total;
+ }
+
+ // If they want the whole thing, style it as all
+ if(button === et2_dialog.OK_BUTTON && rows == this.controller._grid.getTotalCount())
+ {
+ // Add the class, gives more reliable sizing
+ this.div.addClass('print');
+ // Show it all
+ $j('.egwGridView_scrollarea',this.div).css('height','auto');
+ }
+ // We need more rows
+ if(button === 'dialog[all]' || rows > loaded_count)
+ {
+ var count = 0;
+ var fetchedCount = 0;
+ var cancel = false;
+ var nm = this;
+ var dialog = et2_dialog.show_dialog(
+ // Abort the long task if they canceled the data load
+ function() {count = total; cancel=true;window.setTimeout(function() {defer.reject();},0);},
+ egw.lang('Loading'), egw.lang('please wait...'),{},[
+ {"button_id": et2_dialog.CANCEL_BUTTON,"text": 'cancel',id: 'dialog[cancel]',image: 'cancel'}
+ ]
+ );
+
+ // dataFetch() is asyncronous, so all these requests just get fired off...
+ // 200 rows chosen arbitrarily to reduce requests.
+ do {
+ var ctx = {
+ "self": this.controller,
+ "start": count,
+ "count": Math.min(rows,200),
+ "lastModification": this.controller._lastModification
+ };
+ if(nm.controller.dataStorePrefix)
+ {
+ ctx.prefix = nm.controller.dataStorePrefix;
}
- value = parseInt(value);
- if(value > total)
- {
- value = total;
- }
-
- // If they want the whole thing, treat it as all
- if(button == 'dialog[ok]' && value == this.controller._grid.getTotalCount())
- {
- button = 'dialog[all]';
- // Add the class, gives more reliable sizing
- this.div.addClass('print');
- // Show it all
- $j('.egwGridView_scrollarea',this.div).css('height','auto');
- }
- // We need more rows
- if(button == 'dialog[all]' || value > loaded_count)
- {
- var count = 0;
- var fetchedCount = 0;
- var cancel = false;
- var nm = this;
- var dialog = et2_dialog.show_dialog(
- // Abort the long task if they canceled the data load
- function() {count = total; cancel=true;window.setTimeout(function() {defer.reject();},0);},
- egw.lang('Loading'), egw.lang('please wait...'),{},[
- {"button_id": et2_dialog.CANCEL_BUTTON,"text": 'cancel',id: 'dialog[cancel]',image: 'cancel'}
- ]
- );
-
- // dataFetch() is asyncronous, so all these requests just get fired off...
- // 200 rows chosen arbitrarily to reduce requests.
- do {
- var ctx = {
- "self": this.controller,
- "start": count,
- "count": Math.min(value,200),
- "lastModification": this.controller._lastModification
- };
- if(nm.controller.dataStorePrefix)
+ nm.controller.dataFetch({start:count, num_rows: Math.min(rows,200)}, function(data) {
+ // Keep track
+ if(data && data.order)
+ {
+ fetchedCount += data.order.length;
+ }
+ nm.controller._fetchCallback.apply(this, arguments);
+
+ if(fetchedCount >= rows)
+ {
+ if(cancel)
{
- ctx.prefix = nm.controller.dataStorePrefix;
+ dialog.destroy();
+ defer.reject();
+ return;
}
- nm.controller.dataFetch({start:count, num_rows: Math.min(value,200)}, function(data) {
- // Keep track
- if(data && data.order)
- {
- fetchedCount += data.order.length;
- }
- nm.controller._fetchCallback.apply(this, arguments);
-
- if(fetchedCount >= value)
- {
- if(cancel)
- {
- dialog.destroy();
- defer.reject();
- return;
- }
- // Use CSS to hide all but the requested rows
- // Prevents us from showing more than requested, if actual height was less than average
- nm.print_row_selector = ".egwGridView_grid > tbody > tr:not(:nth-child(-n+"+value+"))";
- egw.css(nm.print_row_selector, 'display: none');
-
- // No scrollbar in print view
- $j('.egwGridView_scrollarea',this.div).css('overflow-y','hidden');
- // Show it all
- $j('.egwGridView_scrollarea',this.div).css('height','auto');
-
- // Grid needs to redraw before it can be printed, so wait
- window.setTimeout(jQuery.proxy(function() {
- dialog.destroy();
-
- // Should be OK to print now
- defer.resolve();
- },nm),ET2_GRID_INVALIDATE_TIMEOUT);
-
- }
-
- },ctx);
- count += 200;
- } while (count < value)
- nm.controller._grid.setScrollHeight(nm.controller._grid.getAverageHeight() * (value+1));
- }
- else
- {
- // Don't need more rows, limit to requested and finish
-
- // Show it all
- $j('.egwGridView_scrollarea',this.div).css('height','auto');
-
- // Use CSS to hide all but the requested rows
- // Prevents us from showing more than requested, if actual height was less than average
- this.print_row_selector = ".egwGridView_grid > tbody > tr:not(:nth-child(-n+"+value+"))";
- egw.css(this.print_row_selector, 'display: none');
-
- // No scrollbar in print view
- $j('.egwGridView_scrollarea',this.div).css('overflow-y','hidden');
- // Give dialog a chance to close, or it will be in the print
- window.setTimeout(function() {defer.resolve();}, 0);
- }
- },this),
- egw.lang('How many rows to print'), egw.lang('Print'),
- Math.min(100, total),
- [
- {"button_id": 1,"text": egw.lang('Ok'), id: 'dialog[ok]', image: 'check', "default":true},
- // Nice for small lists, kills server for large lists
- //{"button_id": 2,"text": egw.lang('All'), id: 'dialog[all]', image: ''},
- {"button_id": 0,"text": egw.lang('Cancel'), id: 'dialog[cancel]', image: 'cancel'}
- ]
- );
- return defer;
- }
- else
- {
- // Show all rows
- this.dynheight.innerNode.css('height', 'auto');
- $j('.egwGridView_scrollarea',this.div).css('height','auto');
- }
- // Don't return anything, just work normally
+ // Use CSS to hide all but the requested rows
+ // Prevents us from showing more than requested, if actual height was less than average
+ nm.print_row_selector = ".egwGridView_grid > tbody > tr:not(:nth-child(-n+"+rows+"))";
+ egw.css(nm.print_row_selector, 'display: none');
+
+ // No scrollbar in print view
+ $j('.egwGridView_scrollarea',this.div).css('overflow-y','hidden');
+ // Show it all
+ $j('.egwGridView_scrollarea',this.div).css('height','auto');
+
+ // Grid needs to redraw before it can be printed, so wait
+ window.setTimeout(jQuery.proxy(function() {
+ dialog.destroy();
+
+ // Should be OK to print now
+ defer.resolve();
+ },nm),ET2_GRID_INVALIDATE_TIMEOUT);
+
+ }
+
+ },ctx);
+ count += 200;
+ } while (count < rows)
+ nm.controller._grid.setScrollHeight(nm.controller._grid.getAverageHeight() * (rows+1));
+ }
+ else
+ {
+ // Don't need more rows, limit to requested and finish
+
+ // Show it all
+ $j('.egwGridView_scrollarea',this.div).css('height','auto');
+
+ // Use CSS to hide all but the requested rows
+ // Prevents us from showing more than requested, if actual height was less than average
+ this.print_row_selector = ".egwGridView_grid > tbody > tr:not(:nth-child(-n+"+rows+"))";
+ egw.css(this.print_row_selector, 'display: none');
+
+ // No scrollbar in print view
+ $j('.egwGridView_scrollarea',this.div).css('overflow-y','hidden');
+ // Give dialog a chance to close, or it will be in the print
+ window.setTimeout(function() {defer.resolve();}, 0);
+ }
+ },this);
+
+ var dialog = et2_createWidget("dialog",{
+ // If you use a template, the second parameter will be the value of the template, as if it were submitted.
+ callback: callback, // return false to prevent dialog closing
+ buttons: et2_dialog.BUTTONS_OK_CANCEL,
+ title: 'Print',
+ template:this.egw().link(this.getInstanceManager().template_base_url+'/api/templates/default/nm_print_dialog.xet'),
+ value: {
+ content: {
+ row_count: Math.min(100,total),
+ columns: this.egw().preference(pref,app) || columns_selected
+ },
+ sel_options: {
+ columns: columns
+ }
+ }
+ });
+
+ return defer;
},
/**
@@ -2180,6 +2227,8 @@
delete this.print_row_selector;
}
+ // Restore columns
+ this.set_columns(this.egw().preference(this.options.settings.columnselection_pref,this.getInstanceManager().app));
this.dynheight.outerNode.css('max-width','inherit');
this.resize();
}
Added: trunk/egroupware/api/templates/default/nm_print_dialog.xet
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/templates/default/nm_print_dialog.xet?rev=55792&view=auto
==============================================================================
--- trunk/egroupware/api/templates/default/nm_print_dialog.xet (added)
+++ trunk/egroupware/api/templates/default/nm_print_dialog.xet Thu Apr 21 01:05:43 2016
@@ -1,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE overlay PUBLIC "-//Stylite AG//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
+<!-- $Id$ -->
+<overlay>
+ <template id="nm_print_dialog" template="" lang="" group="0" version="16.1">
+ <vbox>
+ <select id="columns" label="Columns to print" rows="8"/>
+ <integer id="row_count" label="How many rows to print"/>
+ </vbox>
+ </template>
+</overlay>
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.