(core) Improve printing of tables, fix printing of charts, add a browser test.

Summary:
- Include column headers on each page for printing tables.
- Avoid page-breaks inside rows or cards of a card-list.
- Fix printing of charts that did not show up at all before.
- Add a browser test, not great, but somewhat functional.

Test Plan: New test, plus tested manually. Column headers work on Chrome and Firefox (not Safari).

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2636
This commit is contained in:
Dmitry S
2020-10-12 16:00:56 -04:00
parent 4d3777578e
commit 5247521cb8
5 changed files with 71 additions and 12 deletions

View File

@@ -67,15 +67,19 @@ export async function printViewSection(layout: any, viewSection: ViewSectionRec)
const sub2 = dom.onElem(window, 'afterprint', () => {
sub1.dispose();
sub2.dispose();
// To debug printing, set window.debugPringint=1 in the console, then print a section, dismiss
// To debug printing, set window.debugPrinting=1 in the console, then print a section, dismiss
// the print dialog, switch to "@media print" emulation, and you can explore the styles. You'd
// need to reload the page to do it again.
if (!(window as any).debugPrinting) {
// need to call window.finishPrinting() or reload the page to do it again.
if ((window as any).debugPrinting) {
(window as any).finishPrinting = () => prepareToPrint(false);
} else {
prepareToPrint(false);
}
});
window.print();
// Running print on a timeout makes it possible to test printing using selenium, and doesn't
// seem to affect normal printing.
setTimeout(() => window.print(), 0);
}
@@ -97,7 +101,7 @@ export function renderAllRows(
rowModel._index(index);
rowModel.assign(rowId);
const elem = renderRow(rowModel);
html.push(elem.outerHTML);
html.push(`<div class="print-row">${elem.outerHTML}</div>`);
dom.domDispose(elem);
}
});