bpmn-js 9.0.0-subprocesses.0 → 9.0.0-subprocesses.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/dist/assets/bpmn-js.css +58 -0
- package/dist/assets/diagram-js.css +1 -0
- package/dist/bpmn-modeler.development.js +1756 -1632
- package/dist/bpmn-modeler.production.min.js +8 -7
- package/dist/bpmn-navigated-viewer.development.js +20855 -20345
- package/dist/bpmn-navigated-viewer.production.min.js +22 -20
- package/dist/bpmn-viewer.development.js +20049 -19562
- package/dist/bpmn-viewer.production.min.js +22 -20
- package/lib/Modeler.js +1 -4
- package/lib/Viewer.js +2 -2
- package/lib/draw/BpmnRenderer.js +367 -296
- package/lib/draw/PathMap.js +2 -2
- package/lib/features/auto-resize/BpmnAutoResizeProvider.js +3 -6
- package/lib/features/copy-paste/ModdleCopy.js +19 -2
- package/lib/features/modeling/BpmnFactory.js +8 -8
- package/lib/features/modeling/BpmnUpdater.js +0 -5
- package/lib/features/modeling/ElementFactory.js +27 -13
- package/lib/features/modeling/behavior/ResizeBehavior.js +129 -3
- package/lib/features/modeling/behavior/util/ResizeUtil.js +1 -132
- package/lib/features/replace/BpmnReplace.js +38 -16
- package/lib/features/subprocess-navigation/SubprocessCentering.js +55 -0
- package/lib/features/subprocess-navigation/SubprocessCompatibility.js +135 -0
- package/lib/features/subprocess-navigation/SubprocessElements.js +55 -0
- package/lib/features/subprocess-navigation/SubprocessFlows.js +109 -0
- package/lib/features/subprocess-navigation/SubprocessOverlays.js +104 -0
- package/lib/features/subprocess-navigation/index.js +18 -0
- package/lib/import/BpmnImporter.js +59 -10
- package/lib/import/BpmnTreeWalker.js +2 -2
- package/lib/import/Importer.js +4 -4
- package/lib/util/DiUtil.js +1 -0
- package/package.json +2 -2
- package/test/helper/index.js +6 -1
- package/test/util/MockEvents.js +10 -2
- package/lib/features/collapsed-subprocesses/DeleteBehaviour.js +0 -65
- package/lib/features/collapsed-subprocesses/ToggleCollapseBehaviour.js +0 -133
- package/lib/features/collapsed-subprocesses/diagramFactory.js +0 -56
- package/lib/features/collapsed-subprocesses/index.js +0 -12
- package/lib/features/collapsed-subprocesses-navigation/CollapsedSubprocessNavigation.js +0 -198
- package/lib/features/collapsed-subprocesses-navigation/index.js +0 -7
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
|
|
2
|
+
import { selfAndAllChildren } from 'diagram-js/lib/util/Elements';
|
|
3
|
+
import { isExpanded } from '../../util/DiUtil';
|
|
4
|
+
import { getBusinessObject, getDi, is } from '../../util/ModelUtil';
|
|
5
|
+
|
|
6
|
+
export default function SubprocessCompatibility(eventBus, elementRegistry, canvas, moddle, elementFactory, bpmnjs) {
|
|
7
|
+
this._eventBus = eventBus;
|
|
8
|
+
this._elementRegistry = elementRegistry;
|
|
9
|
+
this._canvas = canvas;
|
|
10
|
+
this._bpmnjs = bpmnjs;
|
|
11
|
+
this._moddle = moddle;
|
|
12
|
+
this._elementFactory = elementFactory;
|
|
13
|
+
|
|
14
|
+
var self = this;
|
|
15
|
+
|
|
16
|
+
eventBus.on('import.done', 1500, function() {
|
|
17
|
+
self._handleImport();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
SubprocessCompatibility.prototype._handleImport = function() {
|
|
22
|
+
var elementRegistry = this._elementRegistry;
|
|
23
|
+
var canvas = this._canvas;
|
|
24
|
+
var elementFactory = this._elementFactory;
|
|
25
|
+
var self = this;
|
|
26
|
+
var legacyProcesses = elementRegistry.filter(function(element) {
|
|
27
|
+
return is(element, 'bpmn:SubProcess') && !isExpanded(element) && element.children && element.children.length;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
legacyProcesses.forEach(function(oldParent) {
|
|
31
|
+
var bo = getBusinessObject(oldParent);
|
|
32
|
+
|
|
33
|
+
var newDiagram = self.createDiagram(bo);
|
|
34
|
+
|
|
35
|
+
var newParent = elementFactory.createRoot(
|
|
36
|
+
{
|
|
37
|
+
id: bo.id,
|
|
38
|
+
type: bo.$type,
|
|
39
|
+
businessObject: bo,
|
|
40
|
+
di: newDiagram.plane
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
newParent.id = newParent.id + '_plane';
|
|
45
|
+
|
|
46
|
+
canvas.createPlane(bo.id, newParent);
|
|
47
|
+
|
|
48
|
+
var elementsToChange = selfAndAllChildren(oldParent).filter(function(el) {
|
|
49
|
+
return el !== oldParent;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
self.moveElementsToRoot(elementsToChange);
|
|
53
|
+
|
|
54
|
+
elementsToChange.forEach(function(el) {
|
|
55
|
+
if (el.parent === oldParent) {
|
|
56
|
+
el.parent = newParent;
|
|
57
|
+
}
|
|
58
|
+
el.hidden = el.parent && (el.parent.hidden || el.parent.collapsed);
|
|
59
|
+
|
|
60
|
+
self.moveToDiPlane(el, newDiagram.plane);
|
|
61
|
+
|
|
62
|
+
self._eventBus.fire('elements.changed', { elements: [el] });
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
SubprocessCompatibility.prototype.moveToDiPlane = function(element, newPlane) {
|
|
69
|
+
var di = getDi(element);
|
|
70
|
+
var containingDiagram = findRootDiagram(di);
|
|
71
|
+
|
|
72
|
+
// Remove DI from old Plane and add it to the new one
|
|
73
|
+
var parentPlaneElement = containingDiagram.plane.get('planeElement');
|
|
74
|
+
parentPlaneElement.splice(parentPlaneElement.indexOf(di), 1);
|
|
75
|
+
newPlane.get('planeElement').push(di);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
SubprocessCompatibility.prototype.moveElementsToRoot = function(elements) {
|
|
79
|
+
var defaultPosition = { x: 180, y: 160 },
|
|
80
|
+
minX = Infinity,
|
|
81
|
+
minY = Infinity;
|
|
82
|
+
|
|
83
|
+
elements.forEach(function(el) {
|
|
84
|
+
minX = Math.min(minX, el.x || Infinity);
|
|
85
|
+
minY = Math.min(minY, el.y || Infinity);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
var xOffset = defaultPosition.x - minX;
|
|
89
|
+
var yOffset = defaultPosition.y - minY;
|
|
90
|
+
|
|
91
|
+
elements.forEach(function(el) {
|
|
92
|
+
if (el.waypoints) {
|
|
93
|
+
el.waypoints.forEach(function(waypoint) {
|
|
94
|
+
waypoint.x = waypoint.x + xOffset;
|
|
95
|
+
waypoint.y = waypoint.y + yOffset;
|
|
96
|
+
});
|
|
97
|
+
} else {
|
|
98
|
+
el.x = el.x + xOffset;
|
|
99
|
+
el.y = el.y + yOffset;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
SubprocessCompatibility.prototype.getDefinitions = function() {
|
|
105
|
+
return this._bpmnjs._definitions || [];
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
SubprocessCompatibility.prototype.getDiagrams = function() {
|
|
109
|
+
return this.getDefinitions().diagrams || [];
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
SubprocessCompatibility.prototype.createDiagram = function(bo) {
|
|
113
|
+
var plane = this._moddle.create('bpmndi:BPMNPlane', { bpmnElement: bo });
|
|
114
|
+
var diagram = this._moddle.create('bpmndi:BPMNDiagram', {
|
|
115
|
+
plane: plane
|
|
116
|
+
});
|
|
117
|
+
plane.$parent = diagram;
|
|
118
|
+
plane.bpmnElement = bo;
|
|
119
|
+
diagram.$parent = this.getDefinitions();
|
|
120
|
+
this.getDiagrams().push(diagram);
|
|
121
|
+
return diagram;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
SubprocessCompatibility.$inject = [ 'eventBus', 'elementRegistry', 'canvas', 'moddle', 'elementFactory', 'bpmnjs' ];
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
// Util
|
|
128
|
+
|
|
129
|
+
var findRootDiagram = function(element) {
|
|
130
|
+
if (is(element, 'bpmndi:BPMNDiagram')) {
|
|
131
|
+
return element;
|
|
132
|
+
} else {
|
|
133
|
+
return findRootDiagram(element.$parent);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getBusinessObject, is } from '../../util/ModelUtil';
|
|
2
|
+
|
|
3
|
+
export default function SubprocessElements(eventBus, elementRegistry, canvas, elementFactory) {
|
|
4
|
+
var attachBoundaries = function() {
|
|
5
|
+
var secondaryShapes = elementRegistry.filter(function(el) {
|
|
6
|
+
return is(el, 'bpmn:SubProcess') && el.isSecondary;
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
secondaryShapes.forEach(function(process) {
|
|
10
|
+
|
|
11
|
+
// Add Boundary events
|
|
12
|
+
if (process.primaryShape && process.primaryShape.attachers) {
|
|
13
|
+
process.primaryShape.attachers.forEach(function(boundary) {
|
|
14
|
+
var bo = getBusinessObject(boundary);
|
|
15
|
+
|
|
16
|
+
var primary = process.primaryShape;
|
|
17
|
+
|
|
18
|
+
var relativeXPos = (boundary.x + 15 - primary.x) / primary.width;
|
|
19
|
+
var relativeYPos = (boundary.y + 15 - primary.y) / primary.height;
|
|
20
|
+
|
|
21
|
+
var dx = process.x + (process.width * relativeXPos) - 15;
|
|
22
|
+
var dy = process.y + (process.height * relativeYPos) - 15;
|
|
23
|
+
|
|
24
|
+
var boundaryShape = elementFactory.createShape({
|
|
25
|
+
id: bo.id + '_secondary',
|
|
26
|
+
businessObject: bo,
|
|
27
|
+
type: 'bpmn:BoundaryEvent',
|
|
28
|
+
hidden: false,
|
|
29
|
+
x: dx,
|
|
30
|
+
y: dy,
|
|
31
|
+
width: 30,
|
|
32
|
+
height: 30,
|
|
33
|
+
isFrame: false,
|
|
34
|
+
isSecondary: true,
|
|
35
|
+
primaryShape: boundary,
|
|
36
|
+
di: boundary.di
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
canvas.addShape(boundaryShape, process.parent);
|
|
40
|
+
|
|
41
|
+
if (!process.attachers) {
|
|
42
|
+
process.attachers = [];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
process.attachers.push(boundaryShape);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
eventBus.on('import.done', attachBoundaries);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
SubprocessElements.$inject = [ 'eventBus', 'elementRegistry', 'canvas', 'elementFactory' ];
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var FLOW_LENGTH = 50;
|
|
2
|
+
var HIGH_RENDER_PRIORITY = 2000;
|
|
3
|
+
|
|
4
|
+
export default function SubprocessFlows(eventBus, config) {
|
|
5
|
+
|
|
6
|
+
var mutedStrokeColor = (config && config.mutedStrokeColor) || '#dddddd';
|
|
7
|
+
|
|
8
|
+
function drawFakeFlows(element, parentGfx) {
|
|
9
|
+
var primary = element.primaryShape;
|
|
10
|
+
|
|
11
|
+
var drawFakeConnection = function(connection, isOutgoing) {
|
|
12
|
+
|
|
13
|
+
var segment;
|
|
14
|
+
if (isOutgoing) {
|
|
15
|
+
segment = connection.waypoints.slice(0, 2);
|
|
16
|
+
|
|
17
|
+
// Reverse order for normalizing
|
|
18
|
+
segment = segment.reverse();
|
|
19
|
+
} else {
|
|
20
|
+
segment = connection.waypoints.slice(connection.waypoints.length - 2);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var endpoint = segment[1];
|
|
24
|
+
|
|
25
|
+
var relativePosition = {
|
|
26
|
+
x: (endpoint.x - primary.x) / primary.width,
|
|
27
|
+
y: (endpoint.y - primary.y) / primary.height
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var anchorPoint = {
|
|
31
|
+
x: endpoint.x - (element.width * relativePosition.x),
|
|
32
|
+
y: endpoint.y - (element.height * relativePosition.y)
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var newWaypoints = segment.map(function(el) {
|
|
36
|
+
return { x: el.x - anchorPoint.x, y: el.y - anchorPoint.y };
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
newWaypoints[0] = normalizeLength(newWaypoints[1], newWaypoints[0], FLOW_LENGTH);
|
|
40
|
+
|
|
41
|
+
var attrs = {
|
|
42
|
+
stroke: mutedStrokeColor
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
if (isOutgoing) {
|
|
46
|
+
|
|
47
|
+
// Reverse order again for correct end marker position
|
|
48
|
+
newWaypoints = newWaypoints.reverse();
|
|
49
|
+
} else {
|
|
50
|
+
|
|
51
|
+
// Remove start marker for incoming flows
|
|
52
|
+
attrs.markerStart = undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
eventBus.fire('render.connection', {
|
|
56
|
+
type: connection.type,
|
|
57
|
+
gfx: parentGfx,
|
|
58
|
+
element: {
|
|
59
|
+
type: connection.type,
|
|
60
|
+
waypoints: newWaypoints,
|
|
61
|
+
di: connection.di,
|
|
62
|
+
businessObject: connection.businessObject
|
|
63
|
+
},
|
|
64
|
+
attrs: attrs
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
primary.incoming && primary.incoming.forEach(function(connection) {
|
|
69
|
+
drawFakeConnection(connection, false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
primary.outgoing && primary.outgoing.forEach(function(connection) {
|
|
73
|
+
drawFakeConnection(connection, true);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
eventBus.on([ 'render.shape' ], HIGH_RENDER_PRIORITY, function(evt, context) {
|
|
78
|
+
var element = context.element,
|
|
79
|
+
visuals = context.gfx;
|
|
80
|
+
|
|
81
|
+
if (element.isSecondary && element.primaryShape) {
|
|
82
|
+
drawFakeFlows(element, visuals);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
SubprocessFlows.$inject = [ 'eventBus', 'config' ];
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
// helpers
|
|
93
|
+
|
|
94
|
+
function normalizeLength(fixedPoint, variablePoint, length) {
|
|
95
|
+
var dx = fixedPoint.x - variablePoint.x,
|
|
96
|
+
dy = fixedPoint.y - variablePoint.y,
|
|
97
|
+
totalDistance = Math.abs(dx) + Math.abs(dy);
|
|
98
|
+
|
|
99
|
+
dx = dx / totalDistance;
|
|
100
|
+
dy = dy / totalDistance;
|
|
101
|
+
|
|
102
|
+
dx *= length;
|
|
103
|
+
dy *= length;
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
x: fixedPoint.x - dx,
|
|
107
|
+
y: fixedPoint.y - dy
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { domify } from 'min-dom';
|
|
2
|
+
|
|
3
|
+
import { escapeHTML } from 'diagram-js/lib/util/EscapeUtil';
|
|
4
|
+
import { getBusinessObject, is } from '../../util/ModelUtil';
|
|
5
|
+
|
|
6
|
+
var ARROW_DOWN_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.81801948,3.50735931 L10.4996894,9.1896894 L10.5,4 L12,4 L12,12 L4,12 L4,10.5 L9.6896894,10.4996894 L3.75735931,4.56801948 C3.46446609,4.27512627 3.46446609,3.80025253 3.75735931,3.50735931 C4.05025253,3.21446609 4.52512627,3.21446609 4.81801948,3.50735931 Z"/></svg>';
|
|
7
|
+
var ARROW_UP_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M11.1819805,12.4926407 L5.5003106,6.8103106 L5.5,12 L4,12 L4,4 L12,4 L12,5.5 L6.3103106,5.5003106 L12.2426407,11.4319805 C12.5355339,11.7248737 12.5355339,12.1997475 12.2426407,12.4926407 C11.9497475,12.7855339 11.4748737,12.7855339 11.1819805,12.4926407 Z"/></svg>';
|
|
8
|
+
|
|
9
|
+
export default function SubprocessOverlays(eventBus, elementRegistry, overlays, canvas) {
|
|
10
|
+
|
|
11
|
+
function createBreadcrumbs(subProcess) {
|
|
12
|
+
var breadcrumbs = domify('<ul class="bjs-breadcrumbs"></ul>');
|
|
13
|
+
var drillUp = domify('<button class="bjs-drilldown">' + ARROW_UP_SVG + '</button>');
|
|
14
|
+
drillUp.addEventListener('click', function() {
|
|
15
|
+
var plane = canvas.findPlane(getBusinessObject(subProcess).id);
|
|
16
|
+
canvas.setActivePlane(plane);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
breadcrumbs.appendChild(drillUp);
|
|
20
|
+
|
|
21
|
+
var parents = getParentChain(subProcess);
|
|
22
|
+
|
|
23
|
+
var path = parents.map(function(el) {
|
|
24
|
+
var title = escapeHTML(el.name) || el.id;
|
|
25
|
+
var link = domify('<li><span class="bjs-crumb"><a title="' + title + '">' + title + '</a></span></li>');
|
|
26
|
+
|
|
27
|
+
link.addEventListener('click', function() {
|
|
28
|
+
if (canvas.getPlane(el.id)) {
|
|
29
|
+
canvas.setActivePlane(el.id);
|
|
30
|
+
} else {
|
|
31
|
+
var plane = canvas.findPlane(el.id);
|
|
32
|
+
canvas.setActivePlane(plane);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return link;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
path.forEach(function(el) {
|
|
40
|
+
breadcrumbs.appendChild(el);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
overlays.add(subProcess, {
|
|
44
|
+
position: {
|
|
45
|
+
top: -30,
|
|
46
|
+
left: -10
|
|
47
|
+
},
|
|
48
|
+
html: breadcrumbs
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var createDrilldown = function(element) {
|
|
53
|
+
var html = domify('<button class="bjs-drilldown">' + ARROW_DOWN_SVG + '</button>');
|
|
54
|
+
|
|
55
|
+
html.addEventListener('click', function() {
|
|
56
|
+
canvas.setActivePlane(element.id);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
overlays.add(element, {
|
|
60
|
+
position: {
|
|
61
|
+
bottom: -7,
|
|
62
|
+
right: -8
|
|
63
|
+
},
|
|
64
|
+
html: html
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var addOverlays = function(elements) {
|
|
69
|
+
elements.forEach(function(element) {
|
|
70
|
+
if (is(element, 'bpmn:SubProcess')
|
|
71
|
+
&& element.collapsed
|
|
72
|
+
&& canvas.getPlane(element.id)) {
|
|
73
|
+
createDrilldown(element);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (is(element, 'bpmn:SubProcess') && element.isSecondary) {
|
|
77
|
+
createBreadcrumbs(element);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
eventBus.on('import.done', function() {
|
|
83
|
+
addOverlays(elementRegistry.filter(function(el) {
|
|
84
|
+
return is(el, 'bpmn:SubProcess');
|
|
85
|
+
}));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
SubprocessOverlays.$inject = [ 'eventBus', 'elementRegistry', 'overlays', 'canvas' ];
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
var getParentChain = function(child) {
|
|
93
|
+
var bo = getBusinessObject(child);
|
|
94
|
+
|
|
95
|
+
var parents = [];
|
|
96
|
+
|
|
97
|
+
for (var element = bo; element; element = element.$parent) {
|
|
98
|
+
if (is(element, 'bpmn:SubProcess') || is(element, 'bpmn:Process')) {
|
|
99
|
+
parents.push(element);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return parents.reverse();
|
|
104
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import OverlaysModule from 'diagram-js/lib/features/overlays';
|
|
2
|
+
import ChangeSupportModule from 'diagram-js/lib/features/change-support';
|
|
3
|
+
|
|
4
|
+
import SubprocessElements from './SubprocessElements';
|
|
5
|
+
import SubprocessCentering from './SubprocessCentering';
|
|
6
|
+
import SubprocessCompatibility from './SubprocessCompatibility';
|
|
7
|
+
import SubprocessOverlays from './SubprocessOverlays';
|
|
8
|
+
import SubprocessFlows from './SubprocessFlows';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
__depends__: [ OverlaysModule, ChangeSupportModule ],
|
|
12
|
+
__init__: [ 'subprocessElements', 'subprocessOverlays', 'subprocessCompatibility', 'subprocessCentering', 'subprocessFlows' ],
|
|
13
|
+
subprocessElements: [ 'type', SubprocessElements ],
|
|
14
|
+
subprocessOverlays: [ 'type', SubprocessOverlays ],
|
|
15
|
+
subprocessCompatibility: [ 'type', SubprocessCompatibility ],
|
|
16
|
+
subprocessCentering: [ 'type', SubprocessCentering ],
|
|
17
|
+
subprocessFlows: ['type', SubprocessFlows]
|
|
18
|
+
};
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
} from '../util/LabelUtil';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
|
+
asBounds,
|
|
14
|
+
asTRBL,
|
|
13
15
|
getMid
|
|
14
16
|
} from 'diagram-js/lib/layout/LayoutUtil';
|
|
15
17
|
|
|
@@ -48,6 +50,32 @@ function getWaypoints(di, source, target) {
|
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
var PLANE_PADDING = 50;
|
|
54
|
+
|
|
55
|
+
function getPlaneBounds(plane) {
|
|
56
|
+
var planeTrbl = {
|
|
57
|
+
top: Infinity,
|
|
58
|
+
right: -Infinity,
|
|
59
|
+
bottom: -Infinity,
|
|
60
|
+
left: Infinity
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
plane.planeElement.forEach(function(element) {
|
|
64
|
+
if (!element.bounds) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var trbl = asTRBL(element.bounds);
|
|
69
|
+
|
|
70
|
+
planeTrbl.top = Math.min(trbl.top, planeTrbl.top);
|
|
71
|
+
planeTrbl.left = Math.min(trbl.left, planeTrbl.left);
|
|
72
|
+
planeTrbl.right = Math.max(trbl.right, planeTrbl.right);
|
|
73
|
+
planeTrbl.bottom = Math.max(trbl.bottom, planeTrbl.bottom);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return asBounds(planeTrbl);
|
|
77
|
+
}
|
|
78
|
+
|
|
51
79
|
function notYetDrawn(translate, semantic, refSemantic, property) {
|
|
52
80
|
return new Error(translate('element {element} referenced by {referenced}#{property} not yet drawn', {
|
|
53
81
|
element: elementToString(refSemantic),
|
|
@@ -93,12 +121,10 @@ BpmnImporter.$inject = [
|
|
|
93
121
|
* Add bpmn element (semantic) to the canvas onto the
|
|
94
122
|
* specified parent shape.
|
|
95
123
|
*/
|
|
96
|
-
BpmnImporter.prototype.add = function(
|
|
124
|
+
BpmnImporter.prototype.add = function(semantic, di, parentElement) {
|
|
97
125
|
var element,
|
|
98
126
|
translate = this._translate,
|
|
99
|
-
hidden
|
|
100
|
-
semantic = context.element,
|
|
101
|
-
di = context.di;
|
|
127
|
+
hidden;
|
|
102
128
|
|
|
103
129
|
var parentIndex;
|
|
104
130
|
|
|
@@ -107,14 +133,36 @@ BpmnImporter.prototype.add = function(context, parentElement) {
|
|
|
107
133
|
// invisible root element (process or collaboration)
|
|
108
134
|
if (is(di, 'bpmndi:BPMNPlane')) {
|
|
109
135
|
|
|
110
|
-
|
|
111
|
-
|
|
136
|
+
if (is(semantic, 'bpmn:SubProcess')) {
|
|
137
|
+
var plane = this._canvas.createPlane(semantic.id, element);
|
|
138
|
+
|
|
139
|
+
// Get size of expanded element
|
|
140
|
+
var bounds = getPlaneBounds(di);
|
|
141
|
+
|
|
142
|
+
var primary = this._elementRegistry.get(semantic.id);
|
|
143
|
+
element = this._elementFactory.createShape(elementData(semantic, di, {
|
|
144
|
+
collapsed: false,
|
|
145
|
+
hidden: false,
|
|
146
|
+
x: bounds.x - PLANE_PADDING,
|
|
147
|
+
y: bounds.y - PLANE_PADDING,
|
|
148
|
+
width: bounds.width + PLANE_PADDING * 2,
|
|
149
|
+
height: bounds.height + PLANE_PADDING * 2,
|
|
150
|
+
isFrame: true
|
|
151
|
+
}));
|
|
152
|
+
|
|
153
|
+
element.id = element.id + '_secondary';
|
|
154
|
+
element.isSecondary = true;
|
|
155
|
+
element.primaryShape = primary;
|
|
112
156
|
|
|
113
|
-
|
|
114
|
-
element.id = element.id + '_layer';
|
|
157
|
+
this._canvas.addShape(element, plane.rootElement);
|
|
115
158
|
}
|
|
159
|
+
else {
|
|
116
160
|
|
|
117
|
-
|
|
161
|
+
// add a virtual element (not being drawn)
|
|
162
|
+
element = this._elementFactory.createRoot(elementData(semantic, di));
|
|
163
|
+
|
|
164
|
+
this._canvas.createPlane(semantic.id, element);
|
|
165
|
+
}
|
|
118
166
|
}
|
|
119
167
|
|
|
120
168
|
// SHAPE
|
|
@@ -122,9 +170,10 @@ BpmnImporter.prototype.add = function(context, parentElement) {
|
|
|
122
170
|
|
|
123
171
|
var collapsed = !isExpanded(semantic, di),
|
|
124
172
|
isFrame = isFrameElement(semantic);
|
|
173
|
+
|
|
125
174
|
hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
|
|
126
175
|
|
|
127
|
-
|
|
176
|
+
bounds = di.bounds;
|
|
128
177
|
|
|
129
178
|
element = this._elementFactory.createShape(elementData(semantic, di, {
|
|
130
179
|
collapsed: collapsed,
|
|
@@ -76,11 +76,11 @@ export default function BpmnTreeWalker(handler, translate) {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
// call handler
|
|
79
|
-
return handler.element(
|
|
79
|
+
return handler.element(element, diMap[element.id], ctx);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
function visitRoot(element, diagram) {
|
|
83
|
-
return handler.root(
|
|
83
|
+
return handler.root(element, diMap[element.id], diagram);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
function visitIfDi(element, ctx) {
|
package/lib/import/Importer.js
CHANGED
|
@@ -50,12 +50,12 @@ export function importBpmnDiagram(diagram, definitions, bpmnDiagram) {
|
|
|
50
50
|
|
|
51
51
|
var visitor = {
|
|
52
52
|
|
|
53
|
-
root: function(element) {
|
|
54
|
-
return importer.add(element);
|
|
53
|
+
root: function(element, di) {
|
|
54
|
+
return importer.add(element, di);
|
|
55
55
|
},
|
|
56
56
|
|
|
57
|
-
element: function(element, parentShape) {
|
|
58
|
-
return importer.add(element, parentShape);
|
|
57
|
+
element: function(element, di, parentShape) {
|
|
58
|
+
return importer.add(element, di, parentShape);
|
|
59
59
|
},
|
|
60
60
|
|
|
61
61
|
error: function(message, context) {
|
package/lib/util/DiUtil.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmn-js",
|
|
3
|
-
"version": "9.0.0-subprocesses.
|
|
3
|
+
"version": "9.0.0-subprocesses.1",
|
|
4
4
|
"description": "A bpmn 2.0 toolkit and web modeler",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"bpmn-moddle": "^7.1.2",
|
|
102
102
|
"css.escape": "^1.5.1",
|
|
103
|
-
"diagram-js": "7.
|
|
103
|
+
"diagram-js": "^7.6.0",
|
|
104
104
|
"diagram-js-direct-editing": "^1.6.3",
|
|
105
105
|
"ids": "^1.0.0",
|
|
106
106
|
"inherits": "^2.0.4",
|
package/test/helper/index.js
CHANGED
|
@@ -256,7 +256,12 @@ export function createViewer(container, viewerInstance, xml, diagramId) {
|
|
|
256
256
|
|
|
257
257
|
clearBpmnJS();
|
|
258
258
|
|
|
259
|
-
var viewer = new viewerInstance({
|
|
259
|
+
var viewer = new viewerInstance({
|
|
260
|
+
container: container,
|
|
261
|
+
canvas: {
|
|
262
|
+
deferUpdate: false
|
|
263
|
+
}
|
|
264
|
+
});
|
|
260
265
|
|
|
261
266
|
setBpmnJS(viewer);
|
|
262
267
|
|
package/test/util/MockEvents.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
* specified canvas local coordinates.
|
|
14
14
|
*
|
|
15
15
|
* @param {Point} point of the event local the canvas (closure)
|
|
16
|
-
* @param {Object} data
|
|
16
|
+
* @param {Object} [data]
|
|
17
17
|
*
|
|
18
18
|
* @return {Event} event, scoped to the given canvas
|
|
19
19
|
*/
|
|
@@ -34,7 +34,15 @@ export function createCanvasEvent(position, data) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Create an Event
|
|
39
|
+
*
|
|
40
|
+
* @param {Element} target
|
|
41
|
+
* @param { { x: number, y: number } } position
|
|
42
|
+
* @param {any} [data]
|
|
43
|
+
*
|
|
44
|
+
* @return {Event}
|
|
45
|
+
*/
|
|
38
46
|
export function createEvent(target, position, data) {
|
|
39
47
|
|
|
40
48
|
return getBpmnJS().invoke(function(eventBus) {
|