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", "bootstrap": "^5.2.0",
"bpmn-js": "^9.3.2", "bpmn-js": "^9.3.2",
"bpmn-js-properties-panel": "^1.5.0", "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", "craco": "^0.0.3",
"date-fns": "^2.28.0", "date-fns": "^2.28.0",
"diagram-js": "^8.5.0", "diagram-js": "^8.5.0",
@ -7167,7 +7167,7 @@
}, },
"node_modules/bpmn-js-spiffworkflow": { "node_modules/bpmn-js-spiffworkflow": {
"version": "0.0.8", "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", "license": "MIT",
"dependencies": { "dependencies": {
"@bpmn-io/properties-panel": "^0.19.0", "@bpmn-io/properties-panel": "^0.19.0",
@ -33207,8 +33207,8 @@
} }
}, },
"bpmn-js-spiffworkflow": { "bpmn-js-spiffworkflow": {
"version": "git+ssh://git@github.com/sartography/bpmn-js-spiffworkflow.git#2a15c5e0040ffc4304dd24d4870c4e5aee163944", "version": "git+ssh://git@github.com/sartography/bpmn-js-spiffworkflow.git#e17c9c8d01c890e0dc702de98e22297e9277e9b8",
"from": "bpmn-js-spiffworkflow@sartography/bpmn-js-spiffworkflow#main", "from": "bpmn-js-spiffworkflow@sartography/bpmn-js-spiffworkflow#feature/service_tasks",
"requires": { "requires": {
"@bpmn-io/properties-panel": "^0.19.0", "@bpmn-io/properties-panel": "^0.19.0",
"bpmn-js": "^9.4.0", "bpmn-js": "^9.4.0",

View File

@ -23,7 +23,7 @@
"bootstrap": "^5.2.0", "bootstrap": "^5.2.0",
"bpmn-js": "^9.3.2", "bpmn-js": "^9.3.2",
"bpmn-js-properties-panel": "^1.5.0", "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", "craco": "^0.0.3",
"date-fns": "^2.28.0", "date-fns": "^2.28.0",
"diagram-js": "^8.5.0", "diagram-js": "^8.5.0",

View File

@ -64,6 +64,7 @@ type OwnProps = {
fileName?: string; fileName?: string;
onLaunchScriptEditor?: (..._args: any[]) => any; onLaunchScriptEditor?: (..._args: any[]) => any;
onElementClick?: (..._args: any[]) => any; onElementClick?: (..._args: any[]) => any;
onServiceTasksRequested?: (..._args: any[]) => any;
url?: string; url?: string;
}; };
@ -79,6 +80,7 @@ export default function ReactDiagramEditor({
fileName, fileName,
onLaunchScriptEditor, onLaunchScriptEditor,
onElementClick, onElementClick,
onServiceTasksRequested,
url, url,
}: OwnProps) { }: OwnProps) {
const [diagramXMLString, setDiagramXMLString] = useState(''); const [diagramXMLString, setDiagramXMLString] = useState('');
@ -182,6 +184,12 @@ export default function ReactDiagramEditor({
} }
} }
function handleServiceTasksRequested(event: any) {
if (onServiceTasksRequested) {
onServiceTasksRequested(event);
}
}
setDiagramModelerState(diagramModeler); setDiagramModelerState(diagramModeler);
diagramModeler.on('launch.script.editor', (event: any) => { diagramModeler.on('launch.script.editor', (event: any) => {
@ -203,27 +211,8 @@ export default function ReactDiagramEditor({
}); });
diagramModeler.on('spiff.service_tasks.requested', (event: any) => { diagramModeler.on('spiff.service_tasks.requested', (event: any) => {
HttpService.makeCallToBackend({ handleServiceTasksRequested(event);
path: `/service_tasks`,
successCallback: makeApiHandler(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]); }, [diagramModelerState, diagramType, onLaunchScriptEditor, onElementClick]);
useEffect(() => { useEffect(() => {

View File

@ -128,7 +128,20 @@ export default function ProcessModelEditDiagram() {
</Modal> </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) => { const onLaunchScriptEditor = (element: any, modeling: any) => {
setScriptText(element.businessObject.script || ''); setScriptText(element.businessObject.script || '');
setScriptModeling(modeling); setScriptModeling(modeling);
@ -198,6 +211,7 @@ export default function ProcessModelEditDiagram() {
fileName={processModelFile ? (processModelFile as any).name : null} fileName={processModelFile ? (processModelFile as any).name : null}
diagramType="bpmn" diagramType="bpmn"
onLaunchScriptEditor={onLaunchScriptEditor} onLaunchScriptEditor={onLaunchScriptEditor}
onServiceTasksRequested={onServiceTasksRequested}
/> />
); );
}; };