-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table fix #147
Table fix #147
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -475,10 +475,12 @@ const ClinicalEntityDataTable = ({ | |
.sort(sortEntityData); | ||
} | ||
|
||
const styleThickBorderString = `3px solid ${theme.colors.grey}`; | ||
const getHeaderBorder = (key) => | ||
(showCompletionStats && key === completionColumnHeaders.followUps) || | ||
(!showCompletionStats && key === 'donor_id') | ||
? `3px solid ${theme.colors.grey}` | ||
(!showCompletionStats && key === 'donor_id') || | ||
key === 'FO' | ||
? styleThickBorderString | ||
: ''; | ||
|
||
const [stickyDonorIDColumnsWidth, setStickyDonorIDColumnsWidth] = useState(74); | ||
|
@@ -636,71 +638,160 @@ const ClinicalEntityDataTable = ({ | |
borderBottom: `1px solid ${theme.colors.grey_2}`, | ||
}; | ||
|
||
const headerStyle = css` | ||
background-color: ${theme.colors.grey_4}; | ||
border-bottom: 1px solid ${theme.colors.grey_2}; | ||
border-right: 1px solid ${theme.colors.grey_2}; | ||
font-size: 13px; | ||
padding: 5px; | ||
text-align: left; | ||
`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I know it's a contentious point in the community, often labelled as "nit picking", I truly believe alphabetising properties does help preventing duplicates... which in CSS may introduce bugs that can be rather hard to find at times, because of how the order matters (keyword "cascading"). In this tiny list it may seem superfluous, but we should do it everywhere to elicit consistency, right? |
||
|
||
const stickyCSS = css` | ||
background-color: white; | ||
left: 0; | ||
position: sticky !important; | ||
top: 0; | ||
z-index: 1; | ||
`; | ||
|
||
columns = [ | ||
{ | ||
id: 'clinical_core_completion_header', | ||
header: ( | ||
<div | ||
css={css` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
position: relative; | ||
`} | ||
> | ||
CLINICAL CORE COMPLETION | ||
<Tooltip | ||
style={{ position: 'absolute', left: 'calc(100% - 20px)', top: '-2px' }} | ||
html={ | ||
<p | ||
css={css` | ||
margin: 0px; | ||
margin-right: 6px; | ||
`} | ||
> | ||
For clinical completeness, each donor requires: <br /> | ||
DO: at least one Donor record <br /> | ||
PD: at least one Primary Diagnosis record <br /> | ||
NS: all the registered Normal DNA Specimen record <br /> | ||
TS: all the registered Tumour DNA Specimen record <br /> | ||
TR: at least one Treatment record <br /> | ||
FO: at least one Follow Up record <br /> | ||
</p> | ||
} | ||
meta: { customHeader: true }, | ||
sortingFn: sortEntityData, | ||
header: (props) => { | ||
return ( | ||
<th | ||
colSpan={props.colSpan} | ||
css={css` | ||
${headerStyle}; | ||
border-right: 3px solid ${theme.colors.grey}; | ||
`} | ||
> | ||
<Icon name="question_circle" fill="primary_2" width="18px" height="18px" /> | ||
</Tooltip> | ||
</div> | ||
), | ||
<div | ||
css={css` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
position: relative; | ||
`} | ||
> | ||
CLINICAL CORE COMPLETION | ||
<Tooltip | ||
style={{ position: 'absolute', left: 'calc(100% - 20px)', top: '-2px' }} | ||
html={ | ||
<p | ||
css={css` | ||
margin: 0px; | ||
margin-right: 6px; | ||
`} | ||
> | ||
For clinical completeness, each donor requires: <br /> | ||
DO: at least one Donor record <br /> | ||
PD: at least one Primary Diagnosis record <br /> | ||
NS: all the registered Normal DNA Specimen record <br /> | ||
TS: all the registered Tumour DNA Specimen record <br /> | ||
TR: at least one Treatment record <br /> | ||
FO: at least one Follow Up record <br /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not a request for change, because I know this is an established pattern and not something just from this PRjust a thought I had, on how we could do these non-dev business-domain things better for new hires who won't have the background or context (and me, inexcusably). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
</p> | ||
} | ||
> | ||
<Icon name="question_circle" fill="primary_2" width="18px" height="18px" /> | ||
</Tooltip> | ||
</div> | ||
</th> | ||
); | ||
}, | ||
headerStyle: completionHeaderStyle, | ||
columns: columns.slice(0, 7).map((column) => ({ | ||
columns: columns.slice(0, 7).map((column, index) => ({ | ||
...column, | ||
sortingFn: sortEntityData, | ||
header: (props) => { | ||
const value = props.header.id; | ||
const coreCompletionColumnsCount = 7; | ||
const isLastElement = index === coreCompletionColumnsCount - 1; | ||
const isSticky = value === 'donor_id'; | ||
const isSorted = props.sorted; | ||
|
||
return ( | ||
<th | ||
onClick={props.getSortingHandler()} | ||
css={css` | ||
padding: 2px 6px; | ||
font-size: 12px; | ||
:hover { | ||
cursor: pointer; | ||
} | ||
border-bottom: 1px solid ${theme.colors.grey_2}; | ||
border-right: ${isLastElement | ||
? styleThickBorderString | ||
: `1px solid ${theme.colors.grey_2}`}; | ||
${isSticky && stickyCSS} | ||
${isSorted && | ||
`box-shadow: inset 0 ${isSorted === 'asc' ? '' : '-'}3px 0 0 rgb(7 116 211)`}; | ||
`} | ||
> | ||
{value} | ||
</th> | ||
); | ||
}, | ||
maxWidth: noTableData ? 50 : 250, | ||
style: noTableData ? noDataCellStyle : {}, | ||
meta: { customCell: true, customHeader: true }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cool! hadn't seen this property in the react-table docs. or is it a uikit thing perhaps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more a uikit thing. otherwise the |
||
cell: (context) => { | ||
const value = context.getValue(); | ||
const isSticky = context.column.id === 'donor_id'; | ||
|
||
const { isCompletionCell, errorState } = getCellStyles( | ||
const { isCompletionCell, errorState, style } = getCellStyles( | ||
undefined, | ||
context.row, | ||
context.column, | ||
); | ||
|
||
const showSuccessSvg = isCompletionCell && !errorState; | ||
|
||
return showSuccessSvg ? ( | ||
const content = showSuccessSvg ? ( | ||
<Icon name="checkmark" fill="accent1_dimmed" width="12px" height="12px" /> | ||
) : ( | ||
value | ||
); | ||
|
||
return ( | ||
<td | ||
css={css` | ||
border-right: 1px solid ${theme.colors.grey_2}; | ||
${isSticky && stickyCSS} | ||
`} | ||
style={{ | ||
...style, | ||
}} | ||
> | ||
<div | ||
css={css` | ||
font-size: 12px; | ||
padding: 2px 8px; | ||
min-width: 40px; | ||
height: 28px; | ||
`} | ||
> | ||
{content} | ||
</div> | ||
</td> | ||
); | ||
}, | ||
})), | ||
}, | ||
{ | ||
id: 'submitted_donor_data_header', | ||
header: <div>SUBMITTED DONOR DATA</div>, | ||
meta: { customHeader: true }, | ||
header: (props) => ( | ||
<th colSpan={props.colSpan} css={headerStyle}> | ||
<div>SUBMITTED DONOR DATA</div> | ||
</th> | ||
), | ||
headerStyle: dataHeaderStyle, | ||
columns: columns.slice(7).map((column, i) => column), | ||
columns: columns.slice(7), | ||
}, | ||
]; | ||
} | ||
|
@@ -757,6 +848,7 @@ const ClinicalEntityDataTable = ({ | |
/> | ||
</div> | ||
)} | ||
|
||
<TableInfoHeaderContainer | ||
left={ | ||
<Typography | ||
|
@@ -776,6 +868,9 @@ const ClinicalEntityDataTable = ({ | |
withSideBorders | ||
withPagination | ||
showPageSizeOptions | ||
withStripes | ||
enableColumnResizing={false} | ||
enableSorting | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in contrast, as follow up to my earlier "alphabetise all the things" comment, TS does a much better job at identifying and pointing out duplicate React props, so I don't care as much here. ...I'd only advocate for it here for consistency and "coding discipline", and I realise other devs don't feel as strongly about that as I do. |
||
/> | ||
</div> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's
FO
in this context? may be useful to abstract this into a declaratively named constant, to facilitate reading.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's logic like this all over this file.