-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #512 from bcgsc/release/v6.30.0
Release/v6.30.0
- Loading branch information
Showing
135 changed files
with
4,627 additions
and
2,037 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
app/components/DataTable/components/HTMLCellRenderer/index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.HTMLCellRenderer__container .ag-cell-wrapper { | ||
align-items: start; | ||
} |
96 changes: 96 additions & 0 deletions
96
app/components/DataTable/components/HTMLCellRenderer/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { ICellRendererParams } from '@ag-grid-community/core'; | ||
import React, { | ||
useCallback, useEffect, useRef, useState, | ||
} from 'react'; | ||
|
||
import './index.scss'; | ||
|
||
enum DisplayMode { | ||
normal, compact, | ||
} | ||
|
||
type HTMLCellRendererProps = ICellRendererParams & { | ||
mode: DisplayMode; | ||
}; | ||
|
||
const APP_TEXT_CELL_MIN_HEIGHT = 250; | ||
|
||
const HTMLCellRenderer = (props: HTMLCellRendererProps) => { | ||
const { | ||
data: { text }, node, api, mode = DisplayMode.normal, | ||
} = props; | ||
const [dispMode, setDispMode] = useState(mode); | ||
const cellRef = useRef<HTMLDivElement | null>(null); | ||
|
||
useEffect(() => { | ||
const resizeObserver = new ResizeObserver((entries) => { | ||
// onRowHeightChanged would cause ResizeObserver's loop to prematurely terminate | ||
// https://github.com/juggle/resize-observer/issues/103#issuecomment-1711148285 | ||
setTimeout(() => { | ||
if (cellRef.current) { | ||
for (const entry of entries) { | ||
const { height } = cellRef.current.getBoundingClientRect(); | ||
if ( | ||
Number((entry.target as HTMLElement).style.height) | ||
!== height | ||
) { | ||
const htmlContainer = cellRef.current.closest('.HTMLCellRenderer__content'); | ||
if (dispMode === DisplayMode.normal) { | ||
node.setRowHeight(entry.contentRect.height); | ||
api.onRowHeightChanged(); | ||
} else { | ||
if (htmlContainer.clientHeight < APP_TEXT_CELL_MIN_HEIGHT) { | ||
(htmlContainer.closest('[role="gridcell"]') as HTMLElement).style.overflow = 'hidden'; | ||
} | ||
node.setRowHeight(height < APP_TEXT_CELL_MIN_HEIGHT ? height : APP_TEXT_CELL_MIN_HEIGHT); | ||
api.onRowHeightChanged(); | ||
} | ||
} | ||
} | ||
} | ||
}, 0); | ||
}); | ||
|
||
if (cellRef.current) { | ||
resizeObserver.observe(cellRef.current); | ||
} | ||
|
||
return () => { | ||
resizeObserver.disconnect(); | ||
}; | ||
}, [api, node, dispMode]); | ||
|
||
const handleOnClick = useCallback((evt) => { | ||
const gridCellElem = evt.target.closest('[role="gridcell"]'); | ||
|
||
setDispMode((prevMode) => { | ||
if (prevMode === DisplayMode.normal) { | ||
if (gridCellElem.clientHeight > APP_TEXT_CELL_MIN_HEIGHT) { | ||
gridCellElem.style.overflow = 'auto'; | ||
} | ||
return DisplayMode.compact; | ||
} | ||
gridCellElem.style.overflow = 'hidden'; | ||
return DisplayMode.normal; | ||
}); | ||
}, []); | ||
|
||
return ( | ||
// eslint-disable-next-line jsx-a11y/click-events-have-key-events | ||
<div | ||
className="HTMLCellRenderer__content" | ||
onClick={handleOnClick} | ||
ref={cellRef} | ||
role="button" | ||
tabIndex={0} | ||
> | ||
<div className="inner-html" dangerouslySetInnerHTML={{ __html: text }} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export { | ||
DisplayMode, | ||
HTMLCellRenderer, | ||
}; | ||
export default HTMLCellRenderer; |
10 changes: 10 additions & 0 deletions
10
app/components/DataTable/components/HyperlinkCellRenderer/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ICellRendererParams } from '@ag-grid-community/core'; | ||
import React from 'react'; | ||
|
||
const HyperlinkCellRenderer = (pogId: ICellRendererParams): JSX.Element => { | ||
return ( | ||
<a href={"/reports/patients/" + pogId.value}>{pogId.value}</a> | ||
); | ||
} | ||
|
||
export default HyperlinkCellRenderer; |
Oops, something went wrong.