Skip to content

Commit

Permalink
Merge pull request #951 from cornerstonejs/rename-tool-props
Browse files Browse the repository at this point in the history
fix(tools): Rename tools configuration obj as props
  • Loading branch information
galelis authored Jun 3, 2019
2 parents b9db4a5 + 9c5cac2 commit 8556fa4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/store/addTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const logger = getLogger('addTool');
*
* @param {HTMLElement} element The element to add the tool to.
* @param {BaseTool} ApiTool The tool to add to the element.
* @param {Object} [configuration] Override the default tool configuration
* @param {Object} [props] Override the default tool props
* @returns {undefined}
*/
const addToolForElement = function(element, ApiTool, configuration) {
const addToolForElement = function(element, ApiTool, props) {
// Instantiating the tool here makes it harder to accidentally add
// The same tool (by reference) for multiple elements (which would reassign the tool
// To a new element).
const tool = new ApiTool(configuration);
const tool = new ApiTool(props);
const toolAlreadyAddedToElement = getToolForElement(element, tool.name);

if (toolAlreadyAddedToElement) {
Expand All @@ -41,13 +41,13 @@ const addToolForElement = function(element, ApiTool, configuration) {
* @memberof CornerstoneTools
*
* @param {BaseTool} ApiTool The tool to add to each element.
* @param {Object} [configuration] Override the default tool configuration
* @param {Object} [props] Override the default tool configuration
* @returns {undefined}
*/
const addTool = function(ApiTool, configuration) {
_addToolGlobally(ApiTool, configuration);
const addTool = function(ApiTool, props) {
_addToolGlobally(ApiTool, props);
store.state.enabledElements.forEach(element => {
addToolForElement(element, ApiTool, configuration);
addToolForElement(element, ApiTool, props);
});
};

Expand All @@ -59,15 +59,15 @@ const addTool = function(ApiTool, configuration) {
* @function addToolGlobally
*
* @param {BaseTool} ApiTool
* @param {Object} [configuration] Override the default tool configuration
* @param {Object} [props] Override the default tool configuration
* @returns {undefined}
*/
const _addToolGlobally = function(ApiTool, configuration) {
const _addToolGlobally = function(ApiTool, props) {
if (!store.modules.globalConfiguration.state.globalToolSyncEnabled) {
return;
}

const tool = new ApiTool(configuration);
const tool = new ApiTool(props);
const toolAlreadyAddedGlobally =
store.state.globalTools[tool.name] !== undefined;

Expand All @@ -79,7 +79,7 @@ const _addToolGlobally = function(ApiTool, configuration) {

store.state.globalTools[tool.name] = {
tool: ApiTool,
configuration,
props,
activeBindings: [],
};
};
Expand Down
4 changes: 2 additions & 2 deletions src/store/internals/addEnabledElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ function _addGlobalToolsToElement(enabledElement) {
}

Object.keys(store.state.globalTools).forEach(function(key) {
const { tool, configuration } = store.state.globalTools[key];
const { tool, props } = store.state.globalTools[key];

addToolForElement(enabledElement, tool, configuration);
addToolForElement(enabledElement, tool, props);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/store/setToolMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ function _determineStringBindings(toolName, options, interactionTypes) {

if (globalTool) {
// eslint-disable-next-line new-cap
const tool = new globalTool.tool(globalTool.configuration);
const tool = new globalTool.tool(globalTool.props);

tool.supportedInteractionTypes.forEach(interactionType => {
if (
Expand Down

0 comments on commit 8556fa4

Please sign in to comment.