mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-26 12:51:52 +02:00
Fix nm printing did not properly wait for column selection or rows before trying to print
This commit is contained in:
parent
d6bfa7d9ee
commit
8221d66ce2
@ -2853,7 +2853,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
const total = this.controller._grid.getTotalCount();
|
||||
|
||||
// Defer the printing to ask about columns & rows
|
||||
return new Promise((resolve, reject) =>
|
||||
return new Promise(async(resolve, reject) =>
|
||||
{
|
||||
let pref = this.options.settings.columnselection_pref;
|
||||
if(pref.indexOf('nextmatch') == 0)
|
||||
@ -2862,44 +2862,16 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
}
|
||||
const app = this.getInstanceManager().app;
|
||||
|
||||
const columns = {};
|
||||
const columns = [];
|
||||
const columnMgr = this.dataview.getColumnMgr();
|
||||
pref += '_print';
|
||||
const columns_selected = [];
|
||||
|
||||
// Get column names
|
||||
for (let i = 0; i < columnMgr.columns.length; i++)
|
||||
for(var i = 0; i < columnMgr.columns.length; i++)
|
||||
{
|
||||
const col = columnMgr.columns[i];
|
||||
let col = columnMgr.columns[i];
|
||||
const widget = this.columns[i].widget;
|
||||
let colName = this._getColumnName(widget);
|
||||
|
||||
if (col.caption && col.visibility !== et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT &&
|
||||
col.visibility !== et2_dataview_column.ET2_COL_VISIBILITY_DISABLED)
|
||||
{
|
||||
columns[colName] = col.caption;
|
||||
if (col.visibility === et2_dataview_column.ET2_COL_VISIBILITY_VISIBLE) columns_selected.push(colName);
|
||||
}
|
||||
// Custom fields get listed separately
|
||||
if (widget.instanceOf(et2_nextmatch_customfields))
|
||||
{
|
||||
delete (columns[colName]);
|
||||
colName = widget.id;
|
||||
if (col.visibility === et2_dataview_column.ET2_COL_VISIBILITY_VISIBLE && !
|
||||
jQuery.isEmptyObject((<et2_nextmatch_customfields><unknown>widget).customfields)
|
||||
)
|
||||
{
|
||||
columns[colName] = col.caption;
|
||||
for (let field_name in (<et2_nextmatch_customfields><unknown>widget).customfields)
|
||||
{
|
||||
columns[et2_nextmatch_customfields.PREFIX + field_name] = " - " + (<et2_nextmatch_customfields><unknown>widget).customfields[field_name].label;
|
||||
if (widget.options.fields[field_name] && columns_selected.indexOf(colName) >= 0)
|
||||
{
|
||||
columns_selected.push(et2_nextmatch_customfields.PREFIX + field_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
columns.push({...col, widget: widget, name: this._getColumnName(widget)});
|
||||
}
|
||||
|
||||
// Preference exists? Set it now
|
||||
@ -2951,8 +2923,14 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
this.dynheight.outerNode.css('max-width', this.div.css('max-width'));
|
||||
|
||||
// Handle columns
|
||||
this.set_columns(value.columns);
|
||||
this.egw().set_preference(app, pref, value.columns);
|
||||
let column_names = [];
|
||||
value.columns.forEach((col_id) =>
|
||||
{
|
||||
let name = columns.find((col) => col.id == col_id)?.name || ""
|
||||
column_names.push(name || col_id);
|
||||
})
|
||||
this.set_columns(column_names);
|
||||
this.egw().set_preference(app, pref, column_names);
|
||||
|
||||
let rows = parseInt(value.row_count);
|
||||
if(rows > total)
|
||||
@ -3076,17 +3054,22 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
}, 0);
|
||||
}
|
||||
}.bind(this);
|
||||
var value = {
|
||||
const value = {
|
||||
content: {
|
||||
row_count: Math.min(100, total),
|
||||
columns: this.egw().preference(pref, app) || columns_selected,
|
||||
orientation: this.egw().preference(pref + '_orientation', app)
|
||||
},
|
||||
sel_options: {
|
||||
columns: columns
|
||||
modifications: {
|
||||
autoRefresh: {
|
||||
disabled: true
|
||||
},
|
||||
columns: {
|
||||
columns: columns,
|
||||
}
|
||||
}
|
||||
};
|
||||
this._create_print_dialog.call(this, value, callback);
|
||||
await this._create_print_dialog.call(this, value, callback).updateComplete;
|
||||
});
|
||||
}
|
||||
|
||||
@ -3121,6 +3104,8 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
value: value
|
||||
});
|
||||
document.body.appendChild(dialog);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1386,7 +1386,7 @@ export class etemplate2
|
||||
}
|
||||
|
||||
const result = _widget.beforePrint();
|
||||
if(typeof result == "object" && result.done)
|
||||
if(typeof result == "object")
|
||||
{
|
||||
deferred.push(result);
|
||||
}
|
||||
|
@ -1307,9 +1307,11 @@ window.fw_base = (function(){ "use strict"; return Class.extend(
|
||||
appWindow.onafterprint = afterPrint;
|
||||
|
||||
// Wait for everything to be loaded, then send it off
|
||||
jQuery.when.apply(jQuery, deferred).done(function() {
|
||||
Promise.all(deferred).then(() =>
|
||||
{
|
||||
appWindow.setTimeout(appWindow.print, 0);
|
||||
}).fail(function() {
|
||||
}).catch(function ()
|
||||
{
|
||||
afterPrint();
|
||||
});
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<template id="nm_print_dialog" template="" lang="" group="0" version="16.1">
|
||||
<vbox>
|
||||
<description value="Columns to print"/>
|
||||
<select id="columns" multiple="true" selected_first="false"/>
|
||||
<et2-nextmatch-columnselection id="columns"></et2-nextmatch-columnselection>
|
||||
<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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user