Skip to content

Commit 31be104

Browse files
Merge branch 'develop' into bugfix/DEVSU-2194-retain-report-text-formatting
2 parents 6181a5a + d31bac7 commit 31be104

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

app/components/DataTable/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -560,11 +560,11 @@ const DataTable = ({
560560
paginationAutoPageSize={isFullLength}
561561
paginationPageSize={MAX_VISIBLE_ROWS}
562562
autoSizePadding={1}
563-
deltaRowDataMode={canReorder}
563+
immutableData={canReorder}
564564
getRowNodeId={(data) => data.ident}
565565
onRowDragEnd={canReorder ? onRowDragEnd : null}
566566
editType="fullRow"
567-
enableCellTextSelection
567+
enableCellTextSelection={!showReorder}
568568
onFilterChanged={handleFilterAndSortChanged}
569569
onSortChanged={handleFilterAndSortChanged}
570570
noRowsOverlayComponent="NoRowsOverlay"

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

+32-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, {
33
} from 'react';
44
import orderBy from 'lodash/orderBy';
55
import { Typography } from '@mui/material';
6+
import { cloneDeep } from 'lodash';
67

78
import DataTable from '@/components/DataTable';
89
import useReport from '@/hooks/useReport';
@@ -64,7 +65,26 @@ const Therapeutic = ({
6465
] = useState<TherapeuticType[] | Partial<TherapeuticType>[]>([]);
6566

6667
const [showDialog, setShowDialog] = useState<boolean>(false);
67-
const [editData, setEditData] = useState();
68+
const [editData, setEditData] = useState<TherapeuticType>({
69+
ident: null,
70+
createdAt: null,
71+
updatedAt: null,
72+
type: null,
73+
rank: null,
74+
gene: null,
75+
geneGraphkbId: null,
76+
variant: null,
77+
variantGraphkbId: null,
78+
therapy: null,
79+
therapyGraphkbId: null,
80+
context: null,
81+
contextGraphkbId: null,
82+
evidenceLevel: null,
83+
iprEvidenceLevel: null,
84+
evidenceLevelGraphkbId: null,
85+
kbStatementIds: null,
86+
notes: null,
87+
});
6888

6989
const { canEdit } = useReport();
7090
const { report } = useContext(ReportContext);
@@ -108,7 +128,7 @@ const Therapeutic = ({
108128
try {
109129
setShowDialog(false);
110130
let tableData: TherapeuticType[] | Partial<TherapeuticType>[];
111-
let setter: React.Dispatch<React.SetStateAction<TherapeuticType[]>>;
131+
let setter: React.Dispatch<React.SetStateAction<TherapeuticType[] | Partial<TherapeuticType>[]>>;
112132

113133
if (newData) {
114134
if (newData.type === 'therapeutic') {
@@ -142,12 +162,19 @@ const Therapeutic = ({
142162

143163
if (tableType === 'therapeutic') {
144164
setter = setTherapeuticData;
145-
data = therapeuticData;
165+
data = cloneDeep(therapeuticData);
146166
} else {
147167
setter = setChemoresistanceData;
148-
data = chemoresistanceData;
168+
data = cloneDeep(chemoresistanceData);
149169
}
150170

171+
// For datafixes on the front-end, bugs introduced due to data inconsistencies between indexed by 0 or 1
172+
// This forces indexed by 0
173+
data = data.sort((a, b) => a.rank - b.rank).map((row, idx) => {
174+
row.rank = idx;
175+
return row;
176+
});
177+
151178
const newData = data.map((row) => {
152179
if (row.rank === oldRank) {
153180
row.rank = newRank;
@@ -162,6 +189,7 @@ const Therapeutic = ({
162189
return row;
163190
});
164191

192+
// @ts-expect-error - specialized data object vs a general API call
165193
await api.put(`/reports/${report.ident}/therapeutic-targets`, newData).request();
166194
setter(newData);
167195
snackbar.success('Row updated');

0 commit comments

Comments
 (0)