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
|
* @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() {
|
||||||
|
|||||||
@ -36,7 +36,8 @@ class OHIFCornerstoneViewport extends Component {
|
|||||||
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 +227,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