Merge branch 'feat/v2-main' into feat/OHIF-177

This commit is contained in:
Danny Brown authored and GitHub committed 2020-06-25 16:17:50 -04:00
commit 0264e5998d
28 files changed
+513 -47

No files matched your search

+1 -1
View File
@@ -31,7 +31,7 @@
},
"peerDependencies": {
"cornerstone-core": "^2.3.0",
"cornerstone-tools": "^4.12.0",
"cornerstone-tools": "4.16.0",
"cornerstone-wado-image-loader": "^3.1.2",
"dicom-parser": "^1.8.3"
},
@@ -62,7 +62,7 @@ export default class ToolBarService {
this._broadcastChange(this.EVENTS.TOOL_BAR_MODIFIED, {});
}
getButtonSection(key) {
getButtonSection(key, props) {
const buttonSectionIds = this.buttonSections[key];
const buttonsInSection = [];
@@ -79,7 +79,8 @@ export default class ToolBarService {
btnIds.forEach(nestedBtnId => {
const nestedBtn = this.buttons[nestedBtnId];
const mappedNestedBtn = this._mapButtonToDisplay(nestedBtn, key);
const metadata = { isNested: true };
const mappedNestedBtn = this._mapButtonToDisplay(nestedBtn, key, metadata, props);
nestedButtons.push(mappedNestedBtn);
});
@@ -90,7 +91,8 @@ export default class ToolBarService {
} else {
const btnId = btnIdOrArray;
const btn = this.buttons[btnId];
const mappedBtn = this._mapButtonToDisplay(btn, key);
const metadata = { isNested: false };
const mappedBtn = this._mapButtonToDisplay(btn, key, metadata, props);
buttonsInSection.push(mappedBtn);
}
@@ -136,8 +138,8 @@ export default class ToolBarService {
* @param {*} btn
* @param {*} btnSection
*/
_mapButtonToDisplay(btn, btnSection) {
const { id, type, component, props } = btn;
_mapButtonToDisplay(btn, btnSection, metadata, props) {
const { id, type, component } = btn;
const buttonType = this._buttonTypes()[type];
if (!buttonType) {
@@ -146,7 +148,7 @@ export default class ToolBarService {
const onClick = evt => {
if (buttonType.clickHandler) {
buttonType.clickHandler(evt, btn, btnSection);
buttonType.clickHandler(evt, btn, btnSection, metadata, props);
}
if (btn.props.onClick) {
btn.onClick(evt, btn, btnSection);
@@ -154,12 +156,15 @@ export default class ToolBarService {
if (btn.props.clickHandler) {
btn.clickHandler(evt, btn, btnSection);
}
if (props && props.onClick) {
props.onClick(evt, btn, btnSection, props);
}
};
return {
id,
Component: component || buttonType.defaultComponent,
componentProps: Object.assign({}, props, { onClick }), //
componentProps: Object.assign({}, btn.props, { onClick }), //
};
}
}