Api: Wait for et2-link-strings to finish updating before we continue with the print

Avoids printing before the link titles are loaded
This commit is contained in:
nathan 2023-05-24 15:54:36 -06:00
parent b484a289ff
commit 9a5ed1efa3

View File

@ -75,6 +75,7 @@ import {loadWebComponent} from "./Et2Widget/Et2Widget";
import {Et2AccountFilterHeader} from "./Et2Nextmatch/Headers/AccountFilterHeader"; import {Et2AccountFilterHeader} from "./Et2Nextmatch/Headers/AccountFilterHeader";
import {Et2SelectCategory} from "./Et2Select/Et2SelectCategory"; import {Et2SelectCategory} from "./Et2Select/Et2SelectCategory";
import {Et2Searchbox} from "./Et2Textbox/Et2Searchbox"; import {Et2Searchbox} from "./Et2Textbox/Et2Searchbox";
import {LitElement} from "@lion/core";
//import {et2_selectAccount} from "./et2_widget_SelectAccount"; //import {et2_selectAccount} from "./et2_widget_SelectAccount";
let keep_import : Et2AccountFilterHeader let keep_import : Et2AccountFilterHeader
@ -3079,19 +3080,27 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
egw.css(nm.print.row_selector, 'display: none'); egw.css(nm.print.row_selector, 'display: none');
// No scrollbar in print view // No scrollbar in print view
jQuery('.egwGridView_scrollarea', this.div).css('overflow-y', 'hidden'); jQuery('.egwGridView_scrollarea', nm.div).css('overflow-y', 'hidden');
// Show it all // Show it all
jQuery('.egwGridView_scrollarea', this.div).css('height', 'auto'); jQuery('.egwGridView_scrollarea', nm.div).css('height', 'auto');
// Grid needs to redraw before it can be printed, so wait // Grid (& widgets) need to redraw before it can be printed, so wait
window.setTimeout(function() window.setTimeout(function()
{ {
dialog.close(); // et2-link-string are the worst for taking a while
const nodeListArray : LitElement[] = Array.from(nm.div[0].querySelectorAll("et2-link-string"));
// Should be OK to print now const promises = nodeListArray.map(node => node.updateComplete);
resolve(); Promise.all(promises).finally(() =>
}.bind(nm), et2_dataview_grid.ET2_GRID_INVALIDATE_TIMEOUT); {
dialog.close();
// Should be OK to print now
dialog.updateComplete.then(() =>
{
resolve();
});
});
}, 10 * fetchedCount);
} }
}, ctx); }, ctx);