1
1
import * as React from 'react'
2
2
3
- import _ from 'lodash'
4
-
3
+ import { TableCell , TableRow } from 'semantic-ui-react'
5
4
import FamilyLink from '../../shared/components/links/FamilyLink'
6
5
import SampleLink from '../../shared/components/links/SampleLink'
7
6
import SequencingGroupLink from '../../shared/components/links/SequencingGroupLink'
8
7
import sanitiseValue from '../../shared/utilities/sanitiseValue'
9
- import { Assay , NestedParticipant , NestedSample , NestedSequencingGroup } from '../../sm-api/api'
8
+ import {
9
+ Assay ,
10
+ FamilySimple ,
11
+ NestedParticipant ,
12
+ NestedSample ,
13
+ NestedSequencingGroup ,
14
+ ProjectParticipantGridField ,
15
+ } from '../../sm-api/api'
16
+ import { firstColBorder , otherColBorder } from './ProjectGridHeaderGroup'
17
+
18
+ const getBorderStyles = ( idx : number ) => {
19
+ return {
20
+ borderBottom : otherColBorder ,
21
+ borderLeft : idx === 0 ? firstColBorder : otherColBorder ,
22
+ }
23
+ }
10
24
11
25
interface IProjectGridParticipantRowProps {
12
26
projectName : string
@@ -44,8 +58,6 @@ const prepareExternalIds = (ids: Record<string, string>) => {
44
58
. join ( ', ' )
45
59
}
46
60
47
- const border = '1px solid #dee2e6'
48
-
49
61
const FamilyCells : React . FC < {
50
62
fields : ProjectParticipantGridField [ ]
51
63
participant : NestedParticipant
@@ -55,15 +67,11 @@ const FamilyCells: React.FC<{
55
67
} > = ( { fields, participant, backgroundColor, projectName, participantRowSpan } ) => (
56
68
< >
57
69
{ fields . map ( ( field ) => (
58
- < td
70
+ < TableCell
59
71
key = { `${ participant . id } family.${ field . key } ` }
60
72
style = { {
61
- // display: field.is_visible ? 'table-cell' : 'none',
62
73
backgroundColor,
63
- borderRight : border ,
64
- borderBottom : border ,
65
- borderTop : border ,
66
- borderLeft : '2px solid var(--color-border-color)' ,
74
+ ...getBorderStyles ( 0 ) ,
67
75
} }
68
76
rowSpan = { participantRowSpan }
69
77
>
@@ -76,10 +84,10 @@ const FamilyCells: React.FC<{
76
84
</ FamilyLink >
77
85
) : (
78
86
participant . families
79
- . map ( ( fam ) => sanitiseValue ( _ . get ( fam , field . key ) ) )
87
+ . map ( ( fam ) => sanitiseValue ( fam [ field . key as keyof FamilySimple ] ) )
80
88
. join ( ', ' )
81
89
) }
82
- </ td >
90
+ </ TableCell >
83
91
) ) }
84
92
</ >
85
93
)
@@ -93,25 +101,18 @@ const ParticipantCells: React.FC<{
93
101
} > = ( { fields, participant, backgroundColor, projectName, participantRowSpan } ) => (
94
102
< >
95
103
{ fields . map ( ( field , i ) => (
96
- < td
104
+ < TableCell
97
105
style = { {
98
- // display: field.is_visible ? 'table-cell' : 'none',
99
106
backgroundColor,
100
- borderRight : border ,
101
- borderBottom : border ,
102
- borderTop : border ,
103
- borderLeft :
104
- i === 0
105
- ? '2px solid var(--color-border-color)'
106
- : '1px solid var(--color-border-default)' ,
107
+ ...getBorderStyles ( i ) ,
107
108
} }
108
109
key = { `${ participant . id } participant.${ field . key } ` }
109
110
rowSpan = { participantRowSpan }
110
111
>
111
112
{ field . key == 'external_ids'
112
113
? prepareExternalIds ( participant . external_ids || { } )
113
- : sanitiseValue ( _ . get ( participant , field . key ) ) }
114
- </ td >
114
+ : sanitiseValue ( participant [ field . key as keyof NestedParticipant ] ) }
115
+ </ TableCell >
115
116
) ) }
116
117
</ >
117
118
)
@@ -130,8 +131,6 @@ export const ProjectGridParticipantRows: React.FC<IProjectGridParticipantRowProp
130
131
const lengthOfParticipant = nRowsForParticipant ( participant )
131
132
// debugger
132
133
const rows = participant . samples . flatMap ( ( s , sidx ) => {
133
- // const border = '1px solid #dee2e6'
134
-
135
134
const lengthOfSample = nRowsForSample ( s )
136
135
137
136
const participantRowSpan = lengthOfParticipant > 0 ? lengthOfParticipant : undefined
@@ -150,7 +149,7 @@ export const ProjectGridParticipantRows: React.FC<IProjectGridParticipantRowProp
150
149
return assays . map ( ( assay , assayidx ) => {
151
150
const isFirstOfGroup = sidx === 0 && sgidx === 0 && assayidx === 0
152
151
return (
153
- < tr key = { `${ participant . id } -${ s . id } -${ sg . id } -${ assay . id } ` } { ...props } >
152
+ < TableRow key = { `${ participant . id } -${ s . id } -${ sg . id } -${ assay . id } ` } { ...props } >
154
153
{ isFirstOfGroup && (
155
154
< >
156
155
< FamilyCells
@@ -172,18 +171,10 @@ export const ProjectGridParticipantRows: React.FC<IProjectGridParticipantRowProp
172
171
{ sgidx === 0 &&
173
172
assayidx === 0 &&
174
173
sampleFields . map ( ( field , i ) => (
175
- < td
174
+ < TableCell
176
175
style = { {
177
- display : field . is_visible ? 'table-cell' : 'none' ,
178
176
backgroundColor,
179
- borderRight : border ,
180
- borderBottom : border ,
181
- borderTop : border ,
182
- borderLeft :
183
- i === 0
184
- ? '2px solid var(--color-border-color)'
185
- : '1px solid var(--color-border-default)' ,
186
- // border,
177
+ ...getBorderStyles ( i ) ,
187
178
} }
188
179
key = { `${ s . id } sample.${ field . key } ` }
189
180
rowSpan = { samplesRowSpan }
@@ -195,64 +186,45 @@ export const ProjectGridParticipantRows: React.FC<IProjectGridParticipantRowProp
195
186
: s . id }
196
187
</ SampleLink >
197
188
) : (
198
- sanitiseValue ( _ . get ( s , field . key ) )
189
+ sanitiseValue ( s [ field . key as keyof NestedSample ] )
199
190
) }
200
- </ td >
191
+ </ TableCell >
201
192
) ) }
202
193
{ assayidx === 0 &&
203
194
sequencingGroupFields . map ( ( field , i ) => (
204
- < td
195
+ < TableCell
205
196
style = { {
206
- // display: field.is_visible ? 'table-cell' : 'none',
207
- borderRight : border ,
208
- borderBottom : border ,
209
- borderTop : border ,
210
- borderLeft :
211
- i === 0
212
- ? '2px solid var(--color-border-color)'
213
- : '1px solid var(--color-border-default)' ,
197
+ ...getBorderStyles ( i ) ,
214
198
backgroundColor,
215
199
} }
216
200
key = { `${ s . id } sequencing_group.${ field . key } ` }
217
- rowSpan = {
218
- ( sg . assays ?? [ ] ) . length > 0
219
- ? ( sg . assays ?? [ ] ) . length
220
- : undefined
221
- }
201
+ rowSpan = { sg . assays ?. length || undefined }
222
202
>
223
203
{ field . key === 'id' ? (
224
204
< SequencingGroupLink
225
205
projectName = { projectName }
226
206
id = { s . id }
227
- sg_id = { _ . get ( sg , 'id' ) ?. toString ( ) }
207
+ sg_id = { sg . id ?. toString ( ) }
228
208
>
229
- { sanitiseValue ( _ . get ( sg , field . key ) ) }
209
+ { sanitiseValue ( sg . id ) }
230
210
</ SequencingGroupLink >
231
211
) : (
232
- sanitiseValue ( _ . get ( sg , field . key ) )
212
+ sanitiseValue ( sg [ field . key as keyof NestedSequencingGroup ] )
233
213
) }
234
- </ td >
214
+ </ TableCell >
235
215
) ) }
236
216
{ assayFields . map ( ( field , i ) => (
237
- < td
217
+ < TableCell
238
218
style = { {
239
- // display: field.is_visible ? 'table-cell' : 'none',
240
219
backgroundColor,
241
- borderRight : border ,
242
- borderBottom : border ,
243
- borderTop : border ,
244
- borderLeft :
245
- i === 0
246
- ? '2px solid var(--color-border-color)'
247
- : '1px solid var(--color-border-default)' ,
248
- // border,
220
+ ...getBorderStyles ( i ) ,
249
221
} }
250
222
key = { `${ s . id } -assay.${ field . key || field . label } ` }
251
223
>
252
- { sanitiseValue ( _ . get ( assay , field . key ) ) }
253
- </ td >
224
+ { sanitiseValue ( assay [ field . key as keyof Assay ] ) }
225
+ </ TableCell >
254
226
) ) }
255
- </ tr >
227
+ </ TableRow >
256
228
)
257
229
} )
258
230
} )
0 commit comments