Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: toolType to toolName #991

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/stateManagement/toolState.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ function getElementToolStateManager(element) {
* @method addToolState
*
* @param {HTMLElement} element The element.
* @param {string} toolType The toolType of the state.
* @param {string} toolName The toolName of the state.
* @param {Object} measurementData The data to store in the state.
* @returns {undefined}
*/
function addToolState(element, toolType, measurementData) {
function addToolState(element, toolName, measurementData) {
const toolStateManager = getElementToolStateManager(element);

toolStateManager.add(element, toolType, measurementData);
toolStateManager.add(element, toolName, measurementData);

const eventType = EVENTS.MEASUREMENT_ADDED;
const eventData = {
toolType,
toolName,
Copy link
Member

@JamesAPetts JamesAPetts Jun 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking api change. I'm happy to change this as its technically correct, although we should have a deprecated alias with toolType Either that or we PR this to v4 only. What do you think @dannyrb ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think v4 is coming down the pipe soon enough that we should just do it there, and make a note of it in our breaking changes / migration guide.

element,
measurementData,
};
Expand All @@ -58,13 +58,13 @@ function addToolState(element, toolType, measurementData) {
* @name getToolState
*
* @param {HTMLElement} element The element.
* @param {string} toolType The toolType of the state.
* @returns {Object} The element's state for the given toolType.
* @param {string} toolName The toolName of the state.
* @returns {Object} The element's state for the given toolName.
*/
function getToolState(element, toolType) {
function getToolState(element, toolName) {
const toolStateManager = getElementToolStateManager(element);

return toolStateManager.get(element, toolType);
return toolStateManager.get(element, toolName);
}

/**
Expand All @@ -73,13 +73,13 @@ function getToolState(element, toolType) {
* @method removeToolState
*
* @param {HTMLElement} element The element.
* @param {string} toolType The toolType of the state.
* @param {string} toolName The toolName of the state.
* @param {Object} data The data to remove from the toolStateManager.
* @returns {undefined}
*/
function removeToolState(element, toolType, data) {
function removeToolState(element, toolName, data) {
const toolStateManager = getElementToolStateManager(element);
const toolData = toolStateManager.get(element, toolType);
const toolData = toolStateManager.get(element, toolName);
// Find this tool data
let indexOfData = -1;

Expand All @@ -94,7 +94,7 @@ function removeToolState(element, toolType, data) {

const eventType = EVENTS.MEASUREMENT_REMOVED;
const eventData = {
toolType,
toolName,
element,
measurementData: data,
};
Expand All @@ -105,17 +105,17 @@ function removeToolState(element, toolType, data) {

/**
* Removes all toolState from the toolStateManager corresponding to
* the toolType and element.
* the toolName and element.
* @public
* @method clearToolState
*
* @param {HTMLElement} element The element.
* @param {string} toolType The toolType of the state.
* @param {string} toolName The toolName of the state.
* @returns {undefined}
*/
function clearToolState(element, toolType) {
function clearToolState(element, toolName) {
const toolStateManager = getElementToolStateManager(element);
const toolData = toolStateManager.get(element, toolType);
const toolData = toolStateManager.get(element, toolName);

// If any toolData actually exists, clear it
if (toolData !== undefined) {
Expand Down