diff --git a/__tests__/src/actions/annotation.test.js b/__tests__/src/actions/annotation.test.js index 3609486faf6b882657a05c14d2cbed5c689a92e2..5428ce0532b4855fa4043cbd127c8929df04e779 100644 --- a/__tests__/src/actions/annotation.test.js +++ b/__tests__/src/actions/annotation.test.js @@ -133,4 +133,13 @@ describe('annotation actions', () => { }; expect(actions.deselectAnnotation(windowId, canvasId, annotationId)).toEqual(expectedAction); }); + + it('handles the toggleAnnotationDisplay action', () => { + const windowId = 'wId1'; + const expectedAction = { + type: ActionTypes.TOGGLE_ANNOTATION_DISPLAY, + windowId, + }; + expect(actions.toggleAnnotationDisplay(windowId)).toEqual(expectedAction); + }); }); diff --git a/__tests__/src/reducers/windows.test.js b/__tests__/src/reducers/windows.test.js index 800af2f76e37f51e25e441d5400dafc47537ef34..a623cd699b76e06b068b0345494ac1ab82567798 100644 --- a/__tests__/src/reducers/windows.test.js +++ b/__tests__/src/reducers/windows.test.js @@ -345,5 +345,17 @@ describe('windows reducer', () => { expect(windowsReducer(beforeState, action)).toEqual(expectedState); }); }); + + it('handles TOGGLE_ANNOTATION_DISPLAY by toggling the given window\'s displayAllAnnotation value', () => { + const beforeState = { abc123: { displayAllAnnotations: false } }; + const action = { + type: ActionTypes.TOGGLE_ANNOTATION_DISPLAY, windowId: 'abc123', + }; + const expectedState = { + abc123: { displayAllAnnotations: true }, + }; + + expect(windowsReducer(beforeState, action)).toEqual(expectedState); + }); }); }); diff --git a/src/state/actions/action-types.js b/src/state/actions/action-types.js index 64d801cdddf08fe0bb242dec73aa27fcdc34aede..ca23ce29de866ac35abcae61da6b47a604e6bd16 100644 --- a/src/state/actions/action-types.js +++ b/src/state/actions/action-types.js @@ -9,7 +9,7 @@ const ActionTypes = { RECEIVE_ANNOTATION_FAILURE: 'RECEIVE_ANNOTATION_FAILURE', DESELECT_ANNOTATION: 'DESELECT_ANNOTATION', SELECT_ANNOTATION: 'SELECT_ANNOTATION', - + TOGGLE_ANNOTATION_DISPLAY: 'TOGGLE_ANNOTATION_DISPLAY', FOCUS_WINDOW: 'FOCUS_WINDOW', SET_WORKSPACE_FULLSCREEN: 'SET_WORKSPACE_FULLSCREEN', diff --git a/src/state/actions/annotation.js b/src/state/actions/annotation.js index 3fd9c6a18076065fee85fccb17484bfd834293ac..bd18212796de11a22b101896b35c9c6247e42cf7 100644 --- a/src/state/actions/annotation.js +++ b/src/state/actions/annotation.js @@ -93,3 +93,15 @@ export function deselectAnnotation(windowId, canvasId, annotationId) { type: ActionTypes.DESELECT_ANNOTATION, windowId, canvasId, annotationId, }; } + +/** + * toggleAnnotationDisplay - action creator + * + * @param {String} windowId + * @memberof ActionCreators + */ +export function toggleAnnotationDisplay(windowId) { + return { + type: ActionTypes.TOGGLE_ANNOTATION_DISPLAY, windowId, + }; +} diff --git a/src/state/actions/window.js b/src/state/actions/window.js index b80dbf83905f9ee4dd4f9161e792298439e5beb0..07fe00a287d7e2c66aa81eb550da6b7fd2446f93 100644 --- a/src/state/actions/window.js +++ b/src/state/actions/window.js @@ -58,6 +58,7 @@ export function addWindow(options) { companionWindowIds: [cwDefault, cwThumbs], sideBarPanel: 'info', rotation: null, + displayAllAnnotations: false, selectedAnnotations: {}, view: 'single', maximized: false, diff --git a/src/state/reducers/windows.js b/src/state/reducers/windows.js index 8804af7ed5c20bcbfb6ead5bcd4d17a7d76d9e92..771fef401d85bf34e41388adf1201c3b32f9ec28 100644 --- a/src/state/reducers/windows.js +++ b/src/state/reducers/windows.js @@ -143,6 +143,14 @@ export const windowsReducer = (state = {}, action) => { }, }; } + case ActionTypes.TOGGLE_ANNOTATION_DISPLAY: + return { + ...state, + [action.windowId]: { + ...state[action.windowId], + displayAllAnnotations: !state[action.windowId].displayAllAnnotations, + }, + }; default: return state; }