Skip to content

Commit 12d6849

Browse files
committed
chore: reactiveate coalsece on Rapid reports
1 parent 526ee39 commit 12d6849

File tree

4 files changed

+55
-48
lines changed

4 files changed

+55
-48
lines changed

app/components/PrintTable/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ function PrintTable({
244244

245245
useLayoutEffect(() => {
246246
if (!data.length || !tableId) { return; }
247-
class MyHandler extends Handler {
247+
class PrintTableColSpanHandler extends Handler {
248248
// eslint-disable-next-line class-methods-use-this
249249
afterRendered() {
250250
const targetTables: NodeListOf<HTMLTableElement> = document.querySelectorAll(`[data-table-id='${tableId}']`);
@@ -276,7 +276,7 @@ function PrintTable({
276276
}
277277
}
278278
}
279-
registerHandlers(MyHandler);
279+
registerHandlers(PrintTableColSpanHandler);
280280
}, [data, tableId]);
281281

282282
return (

app/handlers/splitRowSpanHandler.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { Handler } from 'pagedjs';
2-
2+
/**
3+
* Handles when a RowSpanned column is split between two pages in print
4+
* It copies over values from original table to empty cells that are supposed to have values in it
5+
*/
36
class SplitRowSpanHandler extends Handler {
47
// eslint-disable-next-line class-methods-use-this
58
afterRendered(pages) {
69
const rowSpanMap = {};
710
pages.forEach((page) => {
811
const originTables = page.element.querySelectorAll('table[data-split-to]:not([data-split-from])');
912
originTables.forEach((t) => {
10-
const rowSpanTds = [...t.querySelectorAll('td[rowspan]')];
13+
const rowSpanTds = [...t.querySelectorAll('td[rowspan]')].filter((td) => td.rowSpan > 1);
1114

1215
rowSpanTds
1316
.filter((td) => td.innerHTML.trim())
@@ -27,7 +30,7 @@ class SplitRowSpanHandler extends Handler {
2730
.forEach((td) => {
2831
const refId = td.getAttribute('data-ref');
2932
const temp = document.createElement('td');
30-
temp.innerHTML = rowSpanMap[refId];
33+
temp.innerHTML = rowSpanMap[refId] ?? '';
3134
td.innerHTML = '';
3235
td.appendChild(temp.cloneNode(true));
3336
});

app/views/PrintView/index.tsx

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
import getImageDataURI from '@/utils/getImageDataURI';
2020
import { SummaryProps } from '@/commonComponents';
2121

22+
import SplitRowSpanHandler from '@/handlers/splitRowSpanHandler';
2223
import Summary from '../ReportView/components/Summary';
2324
import RunningLeft from './components/RunningLeft';
2425
import RunningCenter from './components/RunningCenter';
@@ -34,6 +35,8 @@ const Appendices = lazy(() => import('../ReportView/components/Appendices'));
3435

3536
const reducer = (state, action) => {
3637
switch (action.type) {
38+
case 'summary':
39+
return { ...state, summary: true };
3740
case 'summary-genomic':
3841
return { ...state, summary: true };
3942
case 'summary-tgr':
@@ -176,45 +179,6 @@ const Print = ({
176179
}
177180
}, [params.ident, report]);
178181

179-
useEffect(() => {
180-
if (reportSectionsLoaded
181-
&& template?.sections.length
182-
&& Object.entries(reportSectionsLoaded).every(([section, loaded]) => loaded || !template?.sections.includes(section))
183-
&& !isPrintDialogShown) {
184-
const showPrint = async () => {
185-
const paged = new Previewer();
186-
await paged.preview(document.getElementById('root'), ['index.css'], document.body);
187-
const templateName = report.template.name === 'probe' ? 'targeted_gene' : report.template.name;
188-
const currentDate = new Date();
189-
const year = currentDate.getFullYear();
190-
const month = (currentDate.getMonth() + 1).toString().padStart(2, '0');
191-
const day = currentDate.getDate().toString().padStart(2, '0');
192-
const hours = currentDate.getHours().toString().padStart(2, '0');
193-
const minutes = currentDate.getMinutes().toString().padStart(2, '0');
194-
const seconds = currentDate.getSeconds().toString().padStart(2, '0');
195-
let serverName;
196-
switch (process.env.NODE_ENV) {
197-
case 'development':
198-
serverName = '_iprdev';
199-
break;
200-
case 'staging':
201-
serverName = '_iprstaging';
202-
break;
203-
default:
204-
serverName = '';
205-
break;
206-
}
207-
const formattedDate = `${year}-${month}-${day}_${hours}h${minutes}m${seconds}s`;
208-
209-
document.title = `${report.patientId}${serverName}_${templateName}_report_${formattedDate}`;
210-
211-
window.print();
212-
setIsPrintDialogShown(true);
213-
};
214-
showPrint();
215-
}
216-
}, [isPrintDialogShown, report, reportSectionsLoaded, template]);
217-
218182
const renderSections = useMemo(() => {
219183
if (report && template) { // TODO remove checks on 'summary' and template name once data updated in prod
220184
return (
@@ -267,6 +231,48 @@ const Print = ({
267231
setReport,
268232
}), [report, setReport]);
269233

234+
useEffect(() => {
235+
if (
236+
reportSectionsLoaded
237+
&& template?.sections.length
238+
&& Object.entries(reportSectionsLoaded).every(([section, loaded]) => loaded || !template?.sections.includes(section))
239+
&& !isPrintDialogShown
240+
) {
241+
const showPrint = async () => {
242+
const paged = new Previewer();
243+
paged.registerHandlers(SplitRowSpanHandler);
244+
await paged.preview(document.getElementById('root'), ['index.css'], document.body);
245+
const templateName = report.template.name === 'probe' ? 'targeted_gene' : report.template.name;
246+
const currentDate = new Date();
247+
const year = currentDate.getFullYear();
248+
const month = (currentDate.getMonth() + 1).toString().padStart(2, '0');
249+
const day = currentDate.getDate().toString().padStart(2, '0');
250+
const hours = currentDate.getHours().toString().padStart(2, '0');
251+
const minutes = currentDate.getMinutes().toString().padStart(2, '0');
252+
const seconds = currentDate.getSeconds().toString().padStart(2, '0');
253+
let serverName;
254+
switch (process.env.NODE_ENV) {
255+
case 'development':
256+
serverName = '_iprdev';
257+
break;
258+
case 'staging':
259+
serverName = '_iprstaging';
260+
break;
261+
default:
262+
serverName = '';
263+
break;
264+
}
265+
const formattedDate = `${year}-${month}-${day}_${hours}h${minutes}m${seconds}s`;
266+
267+
document.title = `${report.patientId}${serverName}_${templateName}_report_${formattedDate}`;
268+
269+
window.print();
270+
setIsPrintDialogShown(true);
271+
};
272+
showPrint();
273+
}
274+
}, [isPrintDialogShown, report, reportSectionsLoaded, template]);
275+
270276
return (
271277
<ReportContext.Provider value={reportContextValue}>
272278
<div className={`${printVersion === 'condensedLayout' ? 'condensedLayout' : 'print'}`}>

app/views/ReportView/components/RapidSummary/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,7 @@ const RapidSummary = ({
422422
<PrintTable
423423
data={therapeuticAssociationResults}
424424
columnDefs={therapeuticAssociationColDefs.filter((col) => col.headerName !== 'Actions')}
425-
// DEVSU-2540 - turn off coalescing for now until more permanent solution
426-
// collapseableCols={['genomicEvents', 'Alt/Total (Tumour)', 'tumourAltCount/tumourDepth', 'comments']}
425+
collapseableCols={['genomicEvents', 'Alt/Total (Tumour)', 'tumourAltCount/tumourDepth', 'comments']}
427426
fullWidth
428427
/>
429428
);
@@ -486,8 +485,7 @@ const RapidSummary = ({
486485
<PrintTable
487486
data={cancerRelevanceResults}
488487
columnDefs={cancerRelevanceColDefs.filter((col) => col.headerName !== 'Actions')}
489-
// DEVSU-2540 - turn off coalescing for now until more permanent solution
490-
// collapseableCols={['genomicEvents', 'Alt/Total (Tumour)', 'tumourAltCount/tumourDepth']}
488+
collapseableCols={['genomicEvents', 'Alt/Total (Tumour)', 'tumourAltCount/tumourDepth']}
491489
fullWidth
492490
/>
493491
);

0 commit comments

Comments
 (0)