additional support for service tasks w/ burnettk

This commit is contained in:
jasquat 2022-08-31 17:14:08 -04:00
parent 16fca37017
commit 6c77638902
4 changed files with 28 additions and 25 deletions

8
package-lock.json generated
View File

@ -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",

View File

@ -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",

View File

@ -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(() => {

View File

@ -128,7 +128,20 @@ export default function ProcessModelEditDiagram() {
</Modal>
);
};
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}
/>
);
};