Fix config check in extension init

This commit is contained in:
Igor 2019-12-11 06:54:41 -03:00
parent 5c686268ab
commit a22fd67e13
2 changed files with 11 additions and 15 deletions

View File

@ -102,7 +102,7 @@ export default function init({ servicesManager, configuration }) {
]; ];
/* Add extension tools configuration here. */ /* Add extension tools configuration here. */
const extensionToolsConfiguration = { const internalToolsConfig = {
ArrowAnnotate: { ArrowAnnotate: {
configuration: { configuration: {
getTextCallback: (callback, eventDetails) => getTextCallback: (callback, eventDetails) =>
@ -113,19 +113,15 @@ export default function init({ servicesManager, configuration }) {
}, },
}; };
const isEmpty = obj => Object.keys(obj).length < 1;
if (!isEmpty(configuration.tools) || !isEmpty(extensionToolsConfiguration)) {
/* Add tools with its custom props through extension configuration. */ /* Add tools with its custom props through extension configuration. */
tools.forEach(tool => { tools.forEach(tool => {
const toolName = tool.name.replace('Tool', ''); const toolName = tool.name.replace('Tool', '');
const configurationToolProps = configuration.tools[toolName] || {}; const externalToolsConfig = configuration.tools || {};
const extensionToolProps = extensionToolsConfiguration[toolName]; const externalToolProps = externalToolsConfig[toolName] || {};
let props = merge(extensionToolProps, configurationToolProps); const internalToolProps = internalToolsConfig[toolName] || {};
const props = merge(internalToolProps, externalToolProps);
csTools.addTool(tool, props); csTools.addTool(tool, props);
}); });
} else {
tools.forEach(tool => csTools.addTool(tool));
}
csTools.setToolActive('Pan', { mouseButtonMask: 4 }); csTools.setToolActive('Pan', { mouseButtonMask: 4 });
csTools.setToolActive('Zoom', { mouseButtonMask: 2 }); csTools.setToolActive('Zoom', { mouseButtonMask: 2 });

View File

@ -70,5 +70,5 @@ window.config = {
// ~ Cornerstone Tools // ~ Cornerstone Tools
{ commandName: 'setZoomTool', label: 'Zoom', keys: ['z'] }, { commandName: 'setZoomTool', label: 'Zoom', keys: ['z'] },
], ],
cornerstoneExtensionConfig: { tools: {} }, cornerstoneExtensionConfig: {},
}; };