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;
onSearchProcessModels?: (..._args: any[]) => any;
onElementsChanged?: (..._args: any[]) => any;
onMessagesRequested?: (..._args: any[]) => any;
url?: string;
callers?: ProcessReference[];
activeUserElement?: React.ReactElement;
@ -115,6 +116,7 @@ export default function ReactDiagramEditor({
onElementClick,
onServiceTasksRequested,
onDataStoresRequested,
onMessagesRequested,
onJsonSchemaFilesRequested,
onDmnFilesRequested,
onSearchProcessModels,
@ -334,6 +336,12 @@ export default function ReactDiagramEditor({
}
}
function handleMessagesRequested(event: any) {
if (onMessagesRequested) {
onMessagesRequested(event);
}
}
setDiagramModelerState(diagramModeler);
diagramModeler.on('spiff.script.edit', (event: any) => {
@ -397,6 +405,10 @@ export default function ReactDiagramEditor({
handleDataStoresRequested(event);
});
diagramModeler.on('spiff.messages.requested', (event: any) => {
handleMessagesRequested(event);
});
diagramModeler.on('spiff.json_schema_files.requested', (event: any) => {
if (onJsonSchemaFilesRequested) {
onJsonSchemaFilesRequested(event);
@ -433,6 +445,7 @@ export default function ReactDiagramEditor({
onDmnFilesRequested,
onSearchProcessModels,
onElementsChanged,
onMessagesRequested
]);
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) => {
HttpService.makeCallToBackend({
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) => {
setFileEventBus(event.eventBus);
const re = /.*[-.]schema.json/;
@ -1249,6 +1267,7 @@ export default function ProcessModelEditDiagram() {
onDmnFilesRequested={onDmnFilesRequested}
onSearchProcessModels={onSearchProcessModels}
onElementsChanged={onElementsChanged}
onMessagesRequested={onMessagesRequested}
callers={callers}
activeUserElement={<ActiveUsers />}
disableSaveButton={!diagramHasChanges}