Skip to content

Commit 9abcbaa

Browse files
Merge pull request #608 from bcgsc/bugfix/DEVSU-2587-pcp-tgr-summary-table-attr-update
[DEVSU-2587#2] datafix for PCP-TGR colDfs
2 parents 7e6a6eb + 332fbea commit 9abcbaa

File tree

2 files changed

+36
-43
lines changed
  • app
    • components/DataTable/components/ArrayCellRenderer
    • views/ReportView/components/PharmacoGenomicSummary

2 files changed

+36
-43
lines changed

app/components/DataTable/components/ArrayCellRenderer/index.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import './index.scss';
77
const urlRegex = /^(?:https?:\/\/)?(?:[\w-]+\.)+[a-z]{2,}(?:\/[\w\-\.\/]*)*$/i;
88

99
// eslint-disable-next-line @typescript-eslint/no-explicit-any
10-
const getNestedValue = (obj: any, path: string): any[] => path.split('.').reduce((acc, key) => {
10+
const getNestedValue = (obj: ICellRendererParams['data'], path: string): any[] => path.split('.').reduce((acc, key) => {
1111
if (Array.isArray(acc)) {
1212
return acc.flatMap((item) => (item && item[key] !== undefined ? item[key] : []));
1313
}
1414
return acc && acc[key] !== undefined ? acc[key] : [];
1515
}, obj);
1616

17-
const RenderArrayCell = (fieldPath: string, isLink: boolean): (cellParams: Partial<ICellRendererParams>) => JSX.Element => {
17+
const RenderArrayCell = (fieldPath: string, isLink: boolean = false): (cellParams: Partial<ICellRendererParams>) => JSX.Element => {
1818
if (isLink) {
1919
return function ArrayCell({ data }: ICellRendererParams) {
2020
const fieldData = getNestedValue(data, fieldPath) || [];
@@ -62,14 +62,21 @@ const RenderArrayCell = (fieldPath: string, isLink: boolean): (cellParams: Parti
6262
// Ensure fieldData is always treated as an array
6363
const cellData = Array.isArray(fieldData) ? [...fieldData].sort() : [fieldData];
6464
const [firstVal] = cellData;
65+
// AgGrid doesn't like false to show in table
66+
const firstValString = `${firstVal}`;
6567

6668
return (
6769
<div>
68-
{firstVal ?? ''}
70+
{(firstVal !== null && firstVal !== undefined) ? firstValString : null}
6971
{cellData.length > 1 && <></>}
7072
</div>
7173
);
7274
};
7375
};
7476

77+
export {
78+
getNestedValue,
79+
RenderArrayCell,
80+
};
81+
7582
export default RenderArrayCell;

app/views/ReportView/components/PharmacoGenomicSummary/columnDefs.ts

+26-40
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import ArrayCell from '@/components/DataTable/components/ArrayCellRenderer';
1+
import ArrayCell, { getNestedValue } from '@/components/DataTable/components/ArrayCellRenderer';
22
import getGeneProp from '@/utils/getGeneProp';
33
import { sampleColumnDefs } from '../../common';
4-
// import PharmacoGenomicAssociationRenderer from './components/PharmacoGenomicAssociationRenderer'; DEVSU-2587 WIP @kttkjl
54

65
const COMMON_COL_DEFS = [
76
{
@@ -73,10 +72,11 @@ const COMMON_COL_DEFS = [
7372
},
7473
{
7574
headerName: 'Association',
76-
colId: 'relevance',
77-
field: 'relevance',
75+
colId: 'kbMatchedStatements.relevance',
7876
minWidth: 90,
79-
cellRendererFramework: ArrayCell('kbMatchedStatements.relevance', false),
77+
// ValueGetter is for mostly PrintTable, as ArrayCell has a different way of obtaining value
78+
valueGetter: ({ data }) => getNestedValue(data, 'kbMatchedStatements.relevance'),
79+
cellRendererFramework: ArrayCell('kbMatchedStatements.relevance'),
8080
},
8181
];
8282

@@ -90,75 +90,74 @@ const ACTIONS_COL_DEF = {
9090
suppressMenu: true,
9191
};
9292

93-
const PHARMACOGEN_EVIDENCE_VAL_GETTER = ({ data: { evidenceLevel, reference } }) => {
94-
if (reference && !evidenceLevel) {
95-
return reference;
96-
}
97-
return evidenceLevel;
98-
};
99-
10093
const pharmacoGenomicPrintColumnDefs = [
10194
...COMMON_COL_DEFS,
10295
{
10396
headerName: 'Therapy',
10497
colId: 'context',
10598
field: 'context',
106-
cellRendererFramework: ArrayCell('kbMatchedStatements.context', false),
99+
valueGetter: ({ data }) => getNestedValue(data, 'kbMatchedStatements.context'),
107100
},
108101
{
109102
headerName: 'Evidence',
110103
colId: 'evidenceLevel',
111104
field: 'evidenceLevel',
112-
valueGetter: PHARMACOGEN_EVIDENCE_VAL_GETTER,
113-
cellRendererFramework: ArrayCell('kbMatchedStatements.evidenceLevel', false),
105+
valueGetter: ({ data }) => getNestedValue(data, 'kbMatchedStatements.evidenceLevel'),
114106
},
115107
{
116108
headerName: 'External Source',
117109
colId: 'externalSource',
118110
field: 'externalSource',
119-
cellRendererFramework: ArrayCell('kbMatchedStatements.externalSource', false),
111+
valueGetter: ({ data }) => getNestedValue(data, 'kbMatchedStatements.externalSource'),
120112
},
121113
];
122114

123115
const pharmacoGenomicColumnDefs = [
124116
...COMMON_COL_DEFS,
125117
{
118+
minWidth: 90,
126119
headerName: 'Therapy',
120+
colId: 'context',
127121
field: 'context',
128-
cellRendererFramework: ArrayCell('kbMatchedStatements.context', false),
129-
minWidth: 90,
122+
cellRendererFramework: ArrayCell('kbMatchedStatements.context'),
130123
},
131124
{
132125
headerName: 'Evidence',
133126
colId: 'evidenceLevel',
134127
field: 'evidenceLevel',
135128
minWidth: 90,
136-
valueGetter: PHARMACOGEN_EVIDENCE_VAL_GETTER,
137-
cellRendererFramework: ArrayCell('kbMatchedStatements.evidenceLevel', false),
129+
valueGetter: ({ data }) => getNestedValue(data, 'kbMatchedStatements.evidenceLevel'),
138130
},
139131
{
140-
field: 'externalSource',
141-
cellRendererFramework: ArrayCell('kbMatchedStatements.externalSource', false),
132+
headerName: 'External Source',
133+
colId: 'externalSource',
134+
cellRendererFramework: ArrayCell('kbMatchedStatements.externalSource'),
142135
minWidth: 110,
143136
},
137+
{
138+
headerName: 'External Statement ID',
139+
field: 'externalStatementId',
140+
cellRendererFramework: ArrayCell('kbMatchedStatements.externalStatementId'),
141+
hide: true,
142+
},
144143
{
145144
headerName: 'Context',
146145
colId: 'context',
147146
field: 'context',
148-
cellRendererFramework: ArrayCell('context', false),
147+
cellRendererFramework: ArrayCell('kbMatchedStatements.context'),
149148
hide: true,
150149
},
151150
{
152151
headerName: 'Category',
153152
colId: 'category',
154153
field: 'category',
155-
cellRendererFramework: ArrayCell('category', false),
154+
cellRendererFramework: ArrayCell('kbMatchedStatements.category'),
156155
hide: true,
157156
},
158157
{
159158
headerName: 'Matched Cancer',
160159
field: 'matchedCancer',
161-
cellRendererFramework: ArrayCell('matchedCancer', false),
160+
cellRendererFramework: ArrayCell('kbMatchedStatements.matchedCancer'),
162161
hide: true,
163162
},
164163
{
@@ -170,16 +169,14 @@ const pharmacoGenomicColumnDefs = [
170169
{
171170
headerName: 'Review Status',
172171
field: 'reviewStatus',
172+
cellRendererFramework: ArrayCell('kbMatchedStatements.reviewStatus'),
173173
hide: true,
174174
},
175175
{
176176
headerName: 'Zygosity',
177177
colId: 'zygosity',
178178
hide: true,
179-
valueGetter: (params) => {
180-
const { data: { variant } } = params;
181-
return variant.zygosity;
182-
},
179+
valueGetter: ({ data }) => getNestedValue(data, 'kbMatches.variant.zygosity'),
183180
},
184181
{
185182
headerName: 'Oncogene',
@@ -227,17 +224,6 @@ const pharmacoGenomicColumnDefs = [
227224
field: 'variant.proteinChange',
228225
hide: true,
229226
},
230-
{
231-
headerName: 'External Source',
232-
colId: 'externalSource',
233-
cellRenderer: 'CivicCellRenderer',
234-
hide: true,
235-
},
236-
{
237-
headerName: 'External Statement ID',
238-
field: 'externalStatementId',
239-
hide: true,
240-
},
241227
ACTIONS_COL_DEF,
242228
];
243229

0 commit comments

Comments
 (0)