2022-06-07 14:16:49 -04:00
|
|
|
import BpmnModeler from 'bpmn-js/lib/Modeler';
|
2022-08-05 14:57:30 -04:00
|
|
|
import {
|
|
|
|
BpmnPropertiesPanelModule,
|
|
|
|
BpmnPropertiesProviderModule,
|
|
|
|
} from 'bpmn-js-properties-panel';
|
2022-09-19 11:04:30 -04:00
|
|
|
import diagramXML from '../test/spec/bpmn/basic_message.bpmn';
|
2022-07-08 10:30:21 -04:00
|
|
|
import spiffworkflow from './spiffworkflow';
|
2022-09-20 16:18:59 -04:00
|
|
|
import setupFileOperations from './fileOperations';
|
2022-09-21 09:10:34 -04:00
|
|
|
|
2022-06-15 09:51:46 -04:00
|
|
|
const modelerEl = document.getElementById('modeler');
|
|
|
|
const panelEl = document.getElementById('panel');
|
2022-06-27 17:29:24 -04:00
|
|
|
const spiffModdleExtension = require('./spiffworkflow/moddle/spiffworkflow.json');
|
|
|
|
|
2022-08-04 16:38:40 -04:00
|
|
|
let bpmnModeler;
|
|
|
|
|
2022-09-21 09:10:34 -04: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 15:57:15 -04:00
|
|
|
try {
|
2022-08-04 16:38:40 -04:00
|
|
|
bpmnModeler = new BpmnModeler({
|
2022-08-04 15:57:15 -04:00
|
|
|
container: modelerEl,
|
|
|
|
propertiesPanel: {
|
2022-08-05 14:57:30 -04:00
|
|
|
parent: panelEl,
|
2022-08-04 15:57:15 -04:00
|
|
|
},
|
|
|
|
additionalModules: [
|
|
|
|
spiffworkflow,
|
|
|
|
BpmnPropertiesPanelModule,
|
|
|
|
BpmnPropertiesProviderModule,
|
|
|
|
],
|
|
|
|
moddleExtensions: {
|
2022-08-05 14:57:30 -04:00
|
|
|
spiffworkflowModdle: spiffModdleExtension,
|
|
|
|
},
|
2022-08-04 15:57:15 -04:00
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
if (error.constructor.name === 'AggregateError') {
|
|
|
|
console.log(error.message);
|
|
|
|
console.log(error.name);
|
|
|
|
console.log(error.errors);
|
|
|
|
}
|
2022-08-04 16:38:40 -04:00
|
|
|
throw error;
|
2022-08-04 15:57:15 -04:00
|
|
|
}
|
2022-06-21 17:04:24 -04:00
|
|
|
|
2022-08-04 16:38:40 -04:00
|
|
|
// import XML
|
|
|
|
bpmnModeler.importXML(diagramXML).then(() => {});
|
|
|
|
|
2022-09-21 09:10:34 -04: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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
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',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// 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 16:18:59 -04:00
|
|
|
setupFileOperations(bpmnModeler);
|