* Api - When printing lists ask for print orientation and size columns to fit

This commit is contained in:
nathangray 2019-02-25 14:14:09 -07:00
parent 0b39506d9f
commit 3fcb5e25ba
4 changed files with 38 additions and 5 deletions

View File

@ -2140,6 +2140,31 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_
return; return;
} }
// Set CSS for orientation
this.div.addClass(value.orientation);
this.egw().set_preference(app,pref+'_orientation',value.orientation);
// Try to tell browser about orientation
var css = '@page { size: '+ value.orientation + '; }',
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
style.media = 'print';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
this.orientation_style = style;
// Trigger resize, so we can fit on a page
this.dynheight.outerNode.css('max-width',this.div.css('max-width'));
// Handle columns // Handle columns
this.set_columns(value.columns); this.set_columns(value.columns);
this.egw().set_preference(app,pref,value.columns); this.egw().set_preference(app,pref,value.columns);
@ -2257,7 +2282,8 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_
value: { value: {
content: { content: {
row_count: Math.min(100,total), row_count: Math.min(100,total),
columns: this.egw().preference(pref,app) || columns_selected columns: this.egw().preference(pref,app) || columns_selected,
orientation: this.egw().preference(pref+'_orientation',app)
}, },
sel_options: { sel_options: {
columns: columns columns: columns
@ -2274,7 +2300,9 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_
*/ */
afterPrint: function() { afterPrint: function() {
this.div.removeClass('print'); this.div.removeClass('print landscape portrait');
jQuery(this.orientation_style).remove();
delete this.orientation_style;
// Put scrollbar back // Put scrollbar back
jQuery('.egwGridView_scrollarea',this.div).css('overflow-y',''); jQuery('.egwGridView_scrollarea',this.div).css('overflow-y','');

View File

@ -261,7 +261,7 @@ class Etemplate extends Etemplate\Widget\Template
echo $GLOBALS['egw']->framework->header(); echo $GLOBALS['egw']->framework->header();
if ($output_mode != 2 && !$GLOBALS['egw_info']['flags']['nonavbar']) if ($output_mode != 2 && !$GLOBALS['egw_info']['flags']['nonavbar'])
{ {
parse_navbar(); $GLOBALS['egw']->framework->navbar();
} }
else // mark popups as such, by enclosing everything in div#popupMainDiv else // mark popups as such, by enclosing everything in div#popupMainDiv
{ {

View File

@ -555,9 +555,13 @@ for printing
.et2_nextmatch.print > div { .et2_nextmatch.print > div {
height: auto !important; height: auto !important;
} }
.et2_nextmatch.print { .et2_nextmatch.print.landscape {
/* This is fairly arbitrary, but makes it fit in Chrome and Firefox*/ /* This is fairly arbitrary, but makes it fit in Chrome and Firefox*/
max-width: 700pt !important; max-width: 710pt !important;
}
.et2_nextmatch.print.portrait {
/* This is fairly arbitrary, but makes it fit in Chrome and Firefox*/
max-width: 570pt !important;
} }
/** /**
* Diff widget * Diff widget

View File

@ -7,6 +7,7 @@
<description value="Columns to print"/> <description value="Columns to print"/>
<select id="columns" rows="8" selected_first="false"/> <select id="columns" rows="8" selected_first="false"/>
<integer id="row_count" label="How many rows to print"/> <integer id="row_count" label="How many rows to print"/>
<checkbox id="orientation" toggle_on="Portrait" toggle_off="Landscape" selected_value="portrait" unselected_value="landscape"/>
</vbox> </vbox>
</template> </template>
</overlay> </overlay>