Merge pull request #375 from OHIF/viewport-custom-props
feat(vewportOverlay): Update the extension to be able to pass custom …
This commit is contained in:
commit
768db26bfc
@ -92,6 +92,6 @@
|
|||||||
"@babel/runtime": "^7.2.0",
|
"@babel/runtime": "^7.2.0",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"lodash.throttle": "^4.1.1",
|
"lodash.throttle": "^4.1.1",
|
||||||
"react-cornerstone-viewport": "^0.1.23"
|
"react-cornerstone-viewport": "^0.1.24"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ const globals = {
|
|||||||
'react-dom': 'ReactDOM',
|
'react-dom': 'ReactDOM',
|
||||||
'react-redux': 'ReactRedux',
|
'react-redux': 'ReactRedux',
|
||||||
'react-resize-detector': 'ReactResizeDetector',
|
'react-resize-detector': 'ReactResizeDetector',
|
||||||
|
'react-viewerbase': 'reactViewerbase',
|
||||||
'prop-types': 'PropTypes',
|
'prop-types': 'PropTypes',
|
||||||
'cornerstone-core': 'cornerstone',
|
'cornerstone-core': 'cornerstone',
|
||||||
'cornerstone-wado-image-loader': 'cornerstoneWADOImageLoader',
|
'cornerstone-wado-image-loader': 'cornerstoneWADOImageLoader',
|
||||||
|
|||||||
@ -11,9 +11,18 @@ import ToolbarModule from './ToolbarModule.js';
|
|||||||
* @param children
|
* @param children
|
||||||
* @return {function(*): *}
|
* @return {function(*): *}
|
||||||
*/
|
*/
|
||||||
function withChildren(WrappedComponent, children) {
|
function componentWithProps(WrappedComponent, children, customProps) {
|
||||||
return function(props) {
|
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
|
// https://github.com/whitecolor/yalc
|
||||||
|
|
||||||
export default class OHIFCornerstoneExtension {
|
export default class OHIFCornerstoneExtension {
|
||||||
constructor(children) {
|
constructor(props) {
|
||||||
|
const { children = {}, customProps = {} } = props;
|
||||||
this.children = children;
|
this.children = children;
|
||||||
|
this.customProps = customProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,11 +44,11 @@ export default class OHIFCornerstoneExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getViewportModule() {
|
getViewportModule() {
|
||||||
if (this.children && this.children.viewport) {
|
return componentWithProps(
|
||||||
return withChildren(OHIFCornerstoneViewport, this.children.viewport);
|
OHIFCornerstoneViewport,
|
||||||
}
|
this.children,
|
||||||
|
this.customProps
|
||||||
return OHIFCornerstoneViewport;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSopClassHandler() {
|
getSopClassHandler() {
|
||||||
|
|||||||
@ -32,11 +32,16 @@ class OHIFCornerstoneViewport extends Component {
|
|||||||
viewportData: null
|
viewportData: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
customProps: {}
|
||||||
|
};
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
studies: PropTypes.object,
|
studies: PropTypes.object,
|
||||||
displaySet: PropTypes.object,
|
displaySet: PropTypes.object,
|
||||||
viewportIndex: PropTypes.number,
|
viewportIndex: PropTypes.number,
|
||||||
children: PropTypes.node
|
children: PropTypes.node,
|
||||||
|
customProps: PropTypes.object
|
||||||
};
|
};
|
||||||
|
|
||||||
static id = 'OHIFCornerstoneViewport';
|
static id = 'OHIFCornerstoneViewport';
|
||||||
@ -226,6 +231,7 @@ class OHIFCornerstoneViewport extends Component {
|
|||||||
<ConnectedCornerstoneViewport
|
<ConnectedCornerstoneViewport
|
||||||
viewportData={this.state.viewportData}
|
viewportData={this.state.viewportData}
|
||||||
viewportIndex={this.props.viewportIndex}
|
viewportIndex={this.props.viewportIndex}
|
||||||
|
{...this.props.customProps}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{childrenWithProps}
|
{childrenWithProps}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user