feat(vewportOverlay): Update the extension to be able to pass custom properties to the viewport
This commit is contained in:
parent
c1173e3232
commit
aacd0c68b8
@ -11,9 +11,18 @@ import ToolbarModule from './ToolbarModule.js';
|
||||
* @param children
|
||||
* @return {function(*): *}
|
||||
*/
|
||||
function withChildren(WrappedComponent, children) {
|
||||
function componentWithProps(WrappedComponent, children, customProps) {
|
||||
return function(props) {
|
||||
return <WrappedComponent children={children} { ...props } />;
|
||||
const extraProps = {
|
||||
customProps
|
||||
};
|
||||
if (children.viewport) {
|
||||
extraProps.children = children.viewport;
|
||||
}
|
||||
|
||||
const mergedProps = Object.assign({}, props, extraProps);
|
||||
|
||||
return <WrappedComponent {...mergedProps} />;
|
||||
};
|
||||
}
|
||||
|
||||
@ -21,8 +30,10 @@ function withChildren(WrappedComponent, children) {
|
||||
// https://github.com/whitecolor/yalc
|
||||
|
||||
export default class OHIFCornerstoneExtension {
|
||||
constructor(children) {
|
||||
constructor(props) {
|
||||
const { children = {}, customProps = {} } = props;
|
||||
this.children = children;
|
||||
this.customProps = customProps;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,11 +44,11 @@ export default class OHIFCornerstoneExtension {
|
||||
}
|
||||
|
||||
getViewportModule() {
|
||||
if (this.children && this.children.viewport) {
|
||||
return withChildren(OHIFCornerstoneViewport, this.children.viewport);
|
||||
}
|
||||
|
||||
return OHIFCornerstoneViewport;
|
||||
return componentWithProps(
|
||||
OHIFCornerstoneViewport,
|
||||
this.children,
|
||||
this.customProps
|
||||
);
|
||||
}
|
||||
|
||||
getSopClassHandler() {
|
||||
|
||||
@ -36,7 +36,8 @@ class OHIFCornerstoneViewport extends Component {
|
||||
studies: PropTypes.object,
|
||||
displaySet: PropTypes.object,
|
||||
viewportIndex: PropTypes.number,
|
||||
children: PropTypes.node
|
||||
children: PropTypes.node,
|
||||
customProps: PropTypes.object
|
||||
};
|
||||
|
||||
static id = 'OHIFCornerstoneViewport';
|
||||
@ -226,6 +227,7 @@ class OHIFCornerstoneViewport extends Component {
|
||||
<ConnectedCornerstoneViewport
|
||||
viewportData={this.state.viewportData}
|
||||
viewportIndex={this.props.viewportIndex}
|
||||
{...this.props.customProps}
|
||||
/>
|
||||
)}
|
||||
{childrenWithProps}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user