ohif-viewer/extensions/default/src/Panels/createReportDialogPrompt.tsx

47 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-11-06 13:15:27 +01:00
import PROMPT_RESPONSES from '../utils/_shared/PROMPT_RESPONSES';
export default function CreateReportDialogPrompt({
title = 'Create Report',
extensionManager,
servicesManager,
}): Promise<{
value: string;
dataSourceName: string;
series: string;
action: (typeof PROMPT_RESPONSES)[keyof typeof PROMPT_RESPONSES];
}> {
const { uiDialogService, customizationService } = servicesManager.services;
const dataSources = extensionManager.getDataSourcesForUI();
const ReportDialog = customizationService.getCustomization('ohif.createReportDialog');
const allowMultipleDataSources = window.config.allowMultiSelectExport;
return new Promise(function (resolve, reject) {
uiDialogService.show({
id: 'report-dialog',
title,
content: ReportDialog,
contentProps: {
dataSources: allowMultipleDataSources ? dataSources : undefined,
onSave: async ({ reportName, dataSource: selectedDataSource, series }) => {
resolve({
value: reportName,
dataSourceName: selectedDataSource,
series,
2024-11-06 13:15:27 +01:00
action: PROMPT_RESPONSES.CREATE_REPORT,
});
},
onCancel: () => {
resolve({
2024-11-06 13:15:27 +01:00
action: PROMPT_RESPONSES.CANCEL,
value: undefined,
series: undefined,
dataSourceName: undefined,
});
},
defaultValue: title,
},
});
});
}