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 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
customOnDropHandler: {
$set: props => {
return Promise.resolve({ handled: false });
},
},
};
2 changes: 2 additions & 0 deletions extensions/default/src/getCustomizationModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import menuContentCustomization from './customizations/menuContentCustomization'
import getDataSourceConfigurationCustomization from './customizations/dataSourceConfigurationCustomization';
import progressDropdownCustomization from './customizations/progressDropdownCustomization';
import sortingCriteriaCustomization from './customizations/sortingCriteriaCustomization';
import onDropHandlerCustomization from './customizations/onDropHandlerCustomization';

/**
*
Expand Down Expand Up @@ -46,6 +47,7 @@ export default function getCustomizationModule({ servicesManager, extensionManag
...progressDropdownCustomization,
...sortingCriteriaCustomization,
...defaultContextMenuCustomization,
...onDropHandlerCustomization,
},
},
];
Expand Down
25 changes: 21 additions & 4 deletions platform/app/src/components/ViewportGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,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 @@ -208,8 +213,20 @@ function ViewerViewportGrid(props: withAppTypes) {
}, [viewports]);

const onDropHandler = (viewportId, { displaySetInstanceUID }) => {
const updatedViewports = _getUpdatedViewports(viewportId, displaySetInstanceUID);
viewportGridService.setDisplaySetsForViewports(updatedViewports);
const customOnDropHandler = customizationService.getCustomization('customOnDropHandler');
Jaseel-trenser marked this conversation as resolved.
Show resolved Hide resolved
const dropHandlerPromise = customOnDropHandler({
...props,
viewportId,
displaySetInstanceUID,
appConfig,
});

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

const getViewportPanes = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,26 @@ window.config = {
};
`,
},
{
id: 'customOnDropHandler ',
description:
'CustomOnDropHandler in the viewport grid enables users to handle additional functionalities during the onDrop event in the viewport.',
default: props => {
return Promise.resolve({ handled: false });
},
configuration: `
window.config = {
// rest of window config
customizationService: [
{
customOnDropHandler: {
$set: customOnDropHandler
},
},
],
};
`,
},
];

export const segmentationCustomizations = [
Expand Down
Loading