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

Feat/custom onDropHandler for viewportGrid #4641

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 25 additions & 4 deletions platform/app/src/components/ViewportGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ function ViewerViewportGrid(props: withAppTypes) {
});
const layoutHash = useRef(null);

const { displaySetService, measurementService, hangingProtocolService, uiNotificationService } =
servicesManager.services;
const {
displaySetService,
measurementService,
hangingProtocolService,
uiNotificationService,
customizationService,
} = servicesManager.services;

const generateLayoutHash = () => `${numCols}-${numRows}`;

Expand Down Expand Up @@ -207,8 +212,24 @@ function ViewerViewportGrid(props: withAppTypes) {
}, [viewports]);

const onDropHandler = (viewportId, { displaySetInstanceUID }) => {
const updatedViewports = _getUpdatedViewports(viewportId, displaySetInstanceUID);
viewportGridService.setDisplaySetsForViewports(updatedViewports);
let dropHandlerPromise = Promise.resolve({ handled: false });
const customOnDropHandler = customizationService.get('customHandlers')?.onDropHandler;

if (customOnDropHandler) {
dropHandlerPromise = customOnDropHandler({
viewportId,
displaySetInstanceUID,
appConfig,
...props,
});
}

dropHandlerPromise.then(({ handled }) => {
if (!handled) {
const updatedViewports = _getUpdatedViewports(viewportId, displaySetInstanceUID);
viewportGridService.setDisplaySetsForViewports(updatedViewports);
}
});
};

const getViewportPanes = useCallback(() => {
Expand Down