Skip to content
Snippets Groups Projects
Commit 35785790 authored by Jessie Keck's avatar Jessie Keck
Browse files

Add reducers/actions for toggling All vs. Selected annotations

parent 12825008
No related branches found
No related tags found
No related merge requests found
......@@ -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);
});
});
......@@ -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);
});
});
});
......@@ -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',
......
......@@ -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,
};
}
......@@ -58,6 +58,7 @@ export function addWindow(options) {
companionWindowIds: [cwDefault, cwThumbs],
sideBarPanel: 'info',
rotation: null,
displayAllAnnotations: false,
selectedAnnotations: {},
view: 'single',
maximized: false,
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment