From 6c77638902508ab9131dfba8c4c7e252864f058a Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 31 Aug 2022 17:14:08 -0400 Subject: [PATCH] additional support for service tasks w/ burnettk --- package-lock.json | 8 +++---- package.json | 2 +- src/components/ReactDiagramEditor.tsx | 29 ++++++++------------------ src/routes/ProcessModelEditDiagram.tsx | 14 +++++++++++++ 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 11c12d6..58262a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ "bootstrap": "^5.2.0", "bpmn-js": "^9.3.2", "bpmn-js-properties-panel": "^1.5.0", - "bpmn-js-spiffworkflow": "sartography/bpmn-js-spiffworkflow#main", + "bpmn-js-spiffworkflow": "sartography/bpmn-js-spiffworkflow#feature/service_tasks", "craco": "^0.0.3", "date-fns": "^2.28.0", "diagram-js": "^8.5.0", @@ -7167,7 +7167,7 @@ }, "node_modules/bpmn-js-spiffworkflow": { "version": "0.0.8", - "resolved": "git+ssh://git@github.com/sartography/bpmn-js-spiffworkflow.git#2a15c5e0040ffc4304dd24d4870c4e5aee163944", + "resolved": "git+ssh://git@github.com/sartography/bpmn-js-spiffworkflow.git#e17c9c8d01c890e0dc702de98e22297e9277e9b8", "license": "MIT", "dependencies": { "@bpmn-io/properties-panel": "^0.19.0", @@ -33207,8 +33207,8 @@ } }, "bpmn-js-spiffworkflow": { - "version": "git+ssh://git@github.com/sartography/bpmn-js-spiffworkflow.git#2a15c5e0040ffc4304dd24d4870c4e5aee163944", - "from": "bpmn-js-spiffworkflow@sartography/bpmn-js-spiffworkflow#main", + "version": "git+ssh://git@github.com/sartography/bpmn-js-spiffworkflow.git#e17c9c8d01c890e0dc702de98e22297e9277e9b8", + "from": "bpmn-js-spiffworkflow@sartography/bpmn-js-spiffworkflow#feature/service_tasks", "requires": { "@bpmn-io/properties-panel": "^0.19.0", "bpmn-js": "^9.4.0", diff --git a/package.json b/package.json index 2d86c56..c58ed4b 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "bootstrap": "^5.2.0", "bpmn-js": "^9.3.2", "bpmn-js-properties-panel": "^1.5.0", - "bpmn-js-spiffworkflow": "sartography/bpmn-js-spiffworkflow#main", + "bpmn-js-spiffworkflow": "sartography/bpmn-js-spiffworkflow#feature/service_tasks", "craco": "^0.0.3", "date-fns": "^2.28.0", "diagram-js": "^8.5.0", diff --git a/src/components/ReactDiagramEditor.tsx b/src/components/ReactDiagramEditor.tsx index a298cdb..a39dfde 100644 --- a/src/components/ReactDiagramEditor.tsx +++ b/src/components/ReactDiagramEditor.tsx @@ -64,6 +64,7 @@ type OwnProps = { fileName?: string; onLaunchScriptEditor?: (..._args: any[]) => any; onElementClick?: (..._args: any[]) => any; + onServiceTasksRequested?: (..._args: any[]) => any; url?: string; }; @@ -79,6 +80,7 @@ export default function ReactDiagramEditor({ fileName, onLaunchScriptEditor, onElementClick, + onServiceTasksRequested, url, }: OwnProps) { const [diagramXMLString, setDiagramXMLString] = useState(''); @@ -182,6 +184,12 @@ export default function ReactDiagramEditor({ } } + function handleServiceTasksRequested(event: any) { + if (onServiceTasksRequested) { + onServiceTasksRequested(event); + } + } + setDiagramModelerState(diagramModeler); diagramModeler.on('launch.script.editor', (event: any) => { @@ -203,27 +211,8 @@ export default function ReactDiagramEditor({ }); diagramModeler.on('spiff.service_tasks.requested', (event: any) => { - HttpService.makeCallToBackend({ - path: `/service_tasks`, - successCallback: makeApiHandler(event), - }); + handleServiceTasksRequested(event); }); - - function makeApiHandler(event: any) { - return function (results: any) { - console.log('results', results); - event.eventBus.fire('spiff.service_tasks.returned', { - serviceTaskOperators: results, - }); - }; - } - - // function handleServiceTask(results: any) { - // console.log('results', results); - // event.eventBus.fire('spiff.service_task.data.returned', { - // wePass: 'hello', - // }); - // } }, [diagramModelerState, diagramType, onLaunchScriptEditor, onElementClick]); useEffect(() => { diff --git a/src/routes/ProcessModelEditDiagram.tsx b/src/routes/ProcessModelEditDiagram.tsx index b35d152..e2ffaa2 100644 --- a/src/routes/ProcessModelEditDiagram.tsx +++ b/src/routes/ProcessModelEditDiagram.tsx @@ -128,7 +128,20 @@ export default function ProcessModelEditDiagram() { ); }; + function makeApiHandler(event: any) { + return function fireEvent(results: any) { + event.eventBus.fire('spiff.service_tasks.returned', { + serviceTaskOperators: results, + }); + }; + } + const onServiceTasksRequested = (event: any) => { + HttpService.makeCallToBackend({ + path: `/service_tasks`, + successCallback: makeApiHandler(event), + }); + }; const onLaunchScriptEditor = (element: any, modeling: any) => { setScriptText(element.businessObject.script || ''); setScriptModeling(modeling); @@ -198,6 +211,7 @@ export default function ProcessModelEditDiagram() { fileName={processModelFile ? (processModelFile as any).name : null} diagramType="bpmn" onLaunchScriptEditor={onLaunchScriptEditor} + onServiceTasksRequested={onServiceTasksRequested} /> ); };