2022-06-07 18:16:49 +00:00
|
|
|
import BpmnModeler from 'bpmn-js/lib/Modeler';
|
2022-08-05 18:57:30 +00:00
|
|
|
import {
|
|
|
|
BpmnPropertiesPanelModule,
|
|
|
|
BpmnPropertiesProviderModule,
|
|
|
|
} from 'bpmn-js-properties-panel';
|
2022-09-12 19:31:01 +00:00
|
|
|
import diagramXML from '../test/spec/bpmn/script_task.bpmn';
|
2022-07-08 14:30:21 +00:00
|
|
|
import spiffworkflow from './spiffworkflow';
|
2022-09-20 20:18:59 +00:00
|
|
|
import setupFileOperations from './fileOperations';
|
2022-06-15 19:13:35 +00:00
|
|
|
|
2022-06-15 13:51:46 +00:00
|
|
|
const modelerEl = document.getElementById('modeler');
|
|
|
|
const panelEl = document.getElementById('panel');
|
2022-06-27 21:29:24 +00:00
|
|
|
const spiffModdleExtension = require('./spiffworkflow/moddle/spiffworkflow.json');
|
|
|
|
|
2022-08-04 20:38:40 +00:00
|
|
|
let bpmnModeler;
|
|
|
|
|
2022-09-21 13:10:34 +00:00
|
|
|
/**
|
|
|
|
* This provides an example of how to instantiate a BPMN Modeler configured with
|
|
|
|
* all the extensions and modifications in this application.
|
|
|
|
*/
|
2022-08-04 19:57:15 +00:00
|
|
|
try {
|
2022-08-04 20:38:40 +00:00
|
|
|
bpmnModeler = new BpmnModeler({
|
2022-08-04 19:57:15 +00:00
|
|
|
container: modelerEl,
|
|
|
|
propertiesPanel: {
|
2022-08-05 18:57:30 +00:00
|
|
|
parent: panelEl,
|
2022-08-04 19:57:15 +00:00
|
|
|
},
|
|
|
|
additionalModules: [
|
|
|
|
spiffworkflow,
|
|
|
|
BpmnPropertiesPanelModule,
|
|
|
|
BpmnPropertiesProviderModule,
|
|
|
|
],
|
|
|
|
moddleExtensions: {
|
2022-08-05 18:57:30 +00:00
|
|
|
spiffworkflowModdle: spiffModdleExtension,
|
|
|
|
},
|
2022-08-04 19:57:15 +00:00
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
if (error.constructor.name === 'AggregateError') {
|
|
|
|
console.log(error.message);
|
|
|
|
console.log(error.name);
|
|
|
|
console.log(error.errors);
|
|
|
|
}
|
2022-08-04 20:38:40 +00:00
|
|
|
throw error;
|
2022-08-04 19:57:15 +00:00
|
|
|
}
|
2022-06-21 21:04:24 +00:00
|
|
|
|
2022-08-04 20:38:40 +00:00
|
|
|
// import XML
|
|
|
|
bpmnModeler.importXML(diagramXML).then(() => {});
|
|
|
|
|
2022-07-11 17:57:12 +00:00
|
|
|
/**
|
2022-09-21 13:10:34 +00:00
|
|
|
* It is possible to poplulate certain components using API calls to
|
|
|
|
* a backend. Here we mock out the API call, but this gives you
|
|
|
|
* a sense of how things might work.
|
|
|
|
*
|
2022-07-11 17:57:12 +00:00
|
|
|
*/
|
2022-09-21 13:10:34 +00:00
|
|
|
bpmnModeler.on('spiff.service_tasks.requested', (event) => {
|
|
|
|
event.eventBus.fire('spiff.service_tasks.returned', {
|
|
|
|
serviceTaskOperators: [
|
|
|
|
{
|
|
|
|
id: 'Chuck Norris Fact Service',
|
|
|
|
parameters: [
|
|
|
|
{
|
|
|
|
id: 'category',
|
|
|
|
type: 'string',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2022-09-23 18:32:25 +00:00
|
|
|
{
|
|
|
|
id: 'Fact about a Number',
|
|
|
|
parameters: [
|
|
|
|
{
|
|
|
|
id: 'number',
|
|
|
|
type: 'integer',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2022-09-21 13:10:34 +00:00
|
|
|
],
|
|
|
|
});
|
2022-07-11 17:57:12 +00:00
|
|
|
});
|
2022-06-21 21:04:24 +00:00
|
|
|
|
2022-09-21 13:10:34 +00:00
|
|
|
// This handles the download and upload buttons - it isn't specific to
|
|
|
|
// the BPMN modeler or these extensions, just a quick way to allow you to
|
|
|
|
// create and save files.
|
2022-09-20 20:18:59 +00:00
|
|
|
setupFileOperations(bpmnModeler);
|