define currentDisplaySetData in viewport grid provider
This commit is contained in:
parent
c9a365f7e2
commit
cf30a6da88
@ -12,6 +12,7 @@ const DEFAULT_STATE = {
|
|||||||
numCols: 1,
|
numCols: 1,
|
||||||
viewports: [],
|
viewports: [],
|
||||||
activeViewportIndex: 0,
|
activeViewportIndex: 0,
|
||||||
|
currentDisplaySetData: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ViewportGridContext = createContext(DEFAULT_STATE);
|
export const ViewportGridContext = createContext(DEFAULT_STATE);
|
||||||
@ -19,15 +20,17 @@ export const ViewportGridContext = createContext(DEFAULT_STATE);
|
|||||||
export function ViewportGridProvider({ children, service }) {
|
export function ViewportGridProvider({ children, service }) {
|
||||||
const viewportGridReducer = (state, action) => {
|
const viewportGridReducer = (state, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'SET_ACTIVE_VIEWPORT_INDEX':
|
case 'SET_ACTIVE_VIEWPORT_INDEX': {
|
||||||
return { ...state, ...{ activeViewportIndex: action.payload } };
|
const activeViewportIndex = action.payload;
|
||||||
|
const currentDisplaySetData = state.viewports[activeViewportIndex];
|
||||||
|
return { ...state, ...{ activeViewportIndex, currentDisplaySetData } };
|
||||||
|
}
|
||||||
case 'SET_DISPLAYSET_FOR_VIEWPORT': {
|
case 'SET_DISPLAYSET_FOR_VIEWPORT': {
|
||||||
const { viewportIndex, displaySetInstanceUID } = action.payload;
|
const { viewportIndex, displaySetInstanceUID } = action.payload;
|
||||||
const viewports = state.viewports.slice();
|
const viewports = state.viewports.slice();
|
||||||
|
const currentDisplaySetData = { displaySetInstanceUID };
|
||||||
viewports[viewportIndex] = { displaySetInstanceUID };
|
viewports[viewportIndex] = { displaySetInstanceUID };
|
||||||
|
return { ...state, ...{ viewports, currentDisplaySetData } };
|
||||||
return { ...state, ...{ viewports } };
|
|
||||||
}
|
}
|
||||||
case 'SET_LAYOUT': {
|
case 'SET_LAYOUT': {
|
||||||
const { numCols, numRows } = action.payload;
|
const { numCols, numRows } = action.payload;
|
||||||
@ -55,7 +58,7 @@ export function ViewportGridProvider({ children, service }) {
|
|||||||
|
|
||||||
const [viewportGridState, dispatch] = useReducer(
|
const [viewportGridState, dispatch] = useReducer(
|
||||||
viewportGridReducer,
|
viewportGridReducer,
|
||||||
DEFAULT_STATE,
|
DEFAULT_STATE
|
||||||
);
|
);
|
||||||
|
|
||||||
const getState = useCallback(() => viewportGridState, [viewportGridState]);
|
const getState = useCallback(() => viewportGridState, [viewportGridState]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user