Add Api call

This commit is contained in:
Ayoub ait lachgar 2024-04-02 23:26:54 +00:00
parent b21a3b3ec7
commit 0314946119
2 changed files with 32 additions and 0 deletions

View File

@ -88,6 +88,7 @@ type OwnProps = {
onDmnFilesRequested?: (..._args: any[]) => any; onDmnFilesRequested?: (..._args: any[]) => any;
onSearchProcessModels?: (..._args: any[]) => any; onSearchProcessModels?: (..._args: any[]) => any;
onElementsChanged?: (..._args: any[]) => any; onElementsChanged?: (..._args: any[]) => any;
onMessagesRequested?: (..._args: any[]) => any;
url?: string; url?: string;
callers?: ProcessReference[]; callers?: ProcessReference[];
activeUserElement?: React.ReactElement; activeUserElement?: React.ReactElement;
@ -115,6 +116,7 @@ export default function ReactDiagramEditor({
onElementClick, onElementClick,
onServiceTasksRequested, onServiceTasksRequested,
onDataStoresRequested, onDataStoresRequested,
onMessagesRequested,
onJsonSchemaFilesRequested, onJsonSchemaFilesRequested,
onDmnFilesRequested, onDmnFilesRequested,
onSearchProcessModels, onSearchProcessModels,
@ -334,6 +336,12 @@ export default function ReactDiagramEditor({
} }
} }
function handleMessagesRequested(event: any) {
if (onMessagesRequested) {
onMessagesRequested(event);
}
}
setDiagramModelerState(diagramModeler); setDiagramModelerState(diagramModeler);
diagramModeler.on('spiff.script.edit', (event: any) => { diagramModeler.on('spiff.script.edit', (event: any) => {
@ -397,6 +405,10 @@ export default function ReactDiagramEditor({
handleDataStoresRequested(event); handleDataStoresRequested(event);
}); });
diagramModeler.on('spiff.messages.requested', (event: any) => {
handleMessagesRequested(event);
});
diagramModeler.on('spiff.json_schema_files.requested', (event: any) => { diagramModeler.on('spiff.json_schema_files.requested', (event: any) => {
if (onJsonSchemaFilesRequested) { if (onJsonSchemaFilesRequested) {
onJsonSchemaFilesRequested(event); onJsonSchemaFilesRequested(event);
@ -433,6 +445,7 @@ export default function ReactDiagramEditor({
onDmnFilesRequested, onDmnFilesRequested,
onSearchProcessModels, onSearchProcessModels,
onElementsChanged, onElementsChanged,
onMessagesRequested
]); ]);
useEffect(() => { useEffect(() => {

View File

@ -387,6 +387,15 @@ export default function ProcessModelEditDiagram() {
}; };
}; };
const makeMessagesApiHandler = (event: any) => {
return function fireEvent(results: any) {
console.log('Results', results)
event.eventBus.fire('spiff.messages.returned', {
options: results,
});
};
};
const onServiceTasksRequested = (event: any) => { const onServiceTasksRequested = (event: any) => {
HttpService.makeCallToBackend({ HttpService.makeCallToBackend({
path: `/service-tasks`, path: `/service-tasks`,
@ -403,6 +412,15 @@ export default function ProcessModelEditDiagram() {
}); });
}; };
const onMessagesRequested = (event: any) => {
const processGroupIdentifier =
processModel?.parent_groups?.slice(-1).pop()?.id ?? '';
HttpService.makeCallToBackend({
path: `/message-models?relative_location=${processGroupIdentifier}`,
successCallback: makeMessagesApiHandler(event),
});
};
const onJsonSchemaFilesRequested = (event: any) => { const onJsonSchemaFilesRequested = (event: any) => {
setFileEventBus(event.eventBus); setFileEventBus(event.eventBus);
const re = /.*[-.]schema.json/; const re = /.*[-.]schema.json/;
@ -1249,6 +1267,7 @@ export default function ProcessModelEditDiagram() {
onDmnFilesRequested={onDmnFilesRequested} onDmnFilesRequested={onDmnFilesRequested}
onSearchProcessModels={onSearchProcessModels} onSearchProcessModels={onSearchProcessModels}
onElementsChanged={onElementsChanged} onElementsChanged={onElementsChanged}
onMessagesRequested={onMessagesRequested}
callers={callers} callers={callers}
activeUserElement={<ActiveUsers />} activeUserElement={<ActiveUsers />}
disableSaveButton={!diagramHasChanges} disableSaveButton={!diagramHasChanges}