bpmn-js 9.0.0-subprocesses.1 → 9.0.0-subprocesses.2

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/lib/Viewer.js CHANGED
@@ -4,7 +4,7 @@ import CoreModule from './core';
4
4
  import TranslateModule from 'diagram-js/lib/i18n/translate';
5
5
  import SelectionModule from 'diagram-js/lib/features/selection';
6
6
  import OverlaysModule from 'diagram-js/lib/features/overlays';
7
- import SubprocessNavigationModule from './features/subprocess-navigation';
7
+ import DrilldownModdule from './features/drilldown';
8
8
 
9
9
  import BaseViewer from './BaseViewer';
10
10
 
@@ -68,7 +68,7 @@ Viewer.prototype._modules = [
68
68
  TranslateModule,
69
69
  SelectionModule,
70
70
  OverlaysModule,
71
- SubprocessNavigationModule
71
+ DrilldownModdule
72
72
  ];
73
73
 
74
74
  // default moddle extensions the viewer is composed of
@@ -1464,8 +1464,6 @@ export default function BpmnRenderer(
1464
1464
  stroke = attrs.stroke || getStrokeColor(element, defaultStrokeColor);
1465
1465
 
1466
1466
  attrs = assign({
1467
- fill: fill,
1468
- stroke: stroke,
1469
1467
  markerEnd: marker('association-end', fill, stroke)
1470
1468
  }, attrs);
1471
1469
 
@@ -1479,8 +1477,6 @@ export default function BpmnRenderer(
1479
1477
 
1480
1478
 
1481
1479
  attrs = assign({
1482
- fill: fill,
1483
- stroke: stroke,
1484
1480
  markerEnd: marker('association-end', fill, stroke)
1485
1481
  }, attrs);
1486
1482
 
@@ -1,11 +1,15 @@
1
- var defaultPosition = { x: 100, y: 50 };
2
-
3
- export default function SubprocessCentering(eventBus, canvas) {
1
+ /**
2
+ * Move collapsed subprocesses into view when drilling down. Zoom and scroll
3
+ * are saved in a session.
4
+ *
5
+ * @param {eventBus} eventBus
6
+ * @param {canvas} canvas
7
+ */
8
+ export default function DrilldownCentering(eventBus, canvas) {
4
9
  var currentPlane = 'base';
5
10
  var positionMap = {};
6
11
 
7
12
  eventBus.on('plane.set', function(event) {
8
-
9
13
  var currentViewbox = canvas.viewbox();
10
14
  positionMap[currentPlane] = {
11
15
  x: currentViewbox.x,
@@ -14,25 +18,7 @@ export default function SubprocessCentering(eventBus, canvas) {
14
18
  };
15
19
 
16
20
  var planeId = event.plane.name;
17
- var storedViewbox = positionMap[planeId];
18
-
19
- if (!storedViewbox) {
20
- if (!event.plane.rootElement.isImplicit) {
21
- storedViewbox = {
22
- x: 0,
23
- y: 0,
24
- zoom: 1
25
- };
26
- }
27
- else {
28
- var currentBoundingBox = canvas.getActiveLayer().getBBox();
29
- storedViewbox = {
30
- x: currentBoundingBox.x - defaultPosition.x,
31
- y: currentBoundingBox.y - defaultPosition.y,
32
- zoom: 1
33
- };
34
- }
35
- }
21
+ var storedViewbox = positionMap[planeId] || { x: 0, y: 0, zoom: 1 };
36
22
 
37
23
  var dx = (currentViewbox.x - storedViewbox.x) * currentViewbox.scale,
38
24
  dy = (currentViewbox.y - storedViewbox.y) * currentViewbox.scale;
@@ -52,4 +38,4 @@ export default function SubprocessCentering(eventBus, canvas) {
52
38
  });
53
39
  }
54
40
 
55
- SubprocessCentering.$inject = [ 'eventBus', 'canvas' ];
41
+ DrilldownCentering.$inject = [ 'eventBus', 'canvas' ];
@@ -4,24 +4,26 @@ import { escapeHTML } from 'diagram-js/lib/util/EscapeUtil';
4
4
  import { getBusinessObject, is } from '../../util/ModelUtil';
5
5
 
6
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
7
 
8
+ /**
9
+ * Adds Overlays that allow switching planes on collapsed subprocesses.
10
+ *
11
+ * @param {eventBus} eventBus
12
+ * @param {elementRegistry} elementRegistry
13
+ * @param {overlays} overlays
14
+ * @param {canvas} canvas
15
+ */
16
+ export default function DrilldownOverlays(eventBus, elementRegistry, overlays, canvas) {
17
+ var breadcrumbs = domify('<ul class="bjs-breadcrumbs djs-element-hidden"></ul>');
18
+ var container = canvas.getContainer();
19
+ container.appendChild(breadcrumbs);
20
+
21
+ function updateBreadcrumbs(plane) {
22
+ var subProcess = elementRegistry.get(plane.name);
21
23
  var parents = getParentChain(subProcess);
22
24
 
23
25
  var path = parents.map(function(el) {
24
- var title = escapeHTML(el.name) || el.id;
26
+ var title = escapeHTML(el.name || el.id);
25
27
  var link = domify('<li><span class="bjs-crumb"><a title="' + title + '">' + title + '</a></span></li>');
26
28
 
27
29
  link.addEventListener('click', function() {
@@ -36,20 +38,26 @@ export default function SubprocessOverlays(eventBus, elementRegistry, overlays,
36
38
  return link;
37
39
  });
38
40
 
41
+ breadcrumbs.innerHTML = '';
42
+
43
+ if (path.length > 1) {
44
+ breadcrumbs.classList.remove('djs-element-hidden');
45
+ } else {
46
+ breadcrumbs.classList.add('djs-element-hidden');
47
+ }
48
+
39
49
  path.forEach(function(el) {
40
50
  breadcrumbs.appendChild(el);
41
51
  });
42
-
43
- overlays.add(subProcess, {
44
- position: {
45
- top: -30,
46
- left: -10
47
- },
48
- html: breadcrumbs
49
- });
50
52
  }
51
53
 
52
- var createDrilldown = function(element) {
54
+ eventBus.on('plane.set', function(event) {
55
+ var plane = event.plane;
56
+
57
+ updateBreadcrumbs(plane);
58
+ });
59
+
60
+ var createOverlay = function(element) {
53
61
  var html = domify('<button class="bjs-drilldown">' + ARROW_DOWN_SVG + '</button>');
54
62
 
55
63
  html.addEventListener('click', function() {
@@ -70,11 +78,7 @@ export default function SubprocessOverlays(eventBus, elementRegistry, overlays,
70
78
  if (is(element, 'bpmn:SubProcess')
71
79
  && element.collapsed
72
80
  && canvas.getPlane(element.id)) {
73
- createDrilldown(element);
74
- }
75
-
76
- if (is(element, 'bpmn:SubProcess') && element.isSecondary) {
77
- createBreadcrumbs(element);
81
+ createOverlay(element);
78
82
  }
79
83
  });
80
84
  };
@@ -86,9 +90,10 @@ export default function SubprocessOverlays(eventBus, elementRegistry, overlays,
86
90
  });
87
91
  }
88
92
 
89
- SubprocessOverlays.$inject = [ 'eventBus', 'elementRegistry', 'overlays', 'canvas' ];
93
+ DrilldownOverlays.$inject = [ 'eventBus', 'elementRegistry', 'overlays', 'canvas' ];
90
94
 
91
95
 
96
+ // helpers
92
97
  var getParentChain = function(child) {
93
98
  var bo = getBusinessObject(child);
94
99
 
@@ -0,0 +1,193 @@
1
+
2
+ import { asBounds, asTRBL } from 'diagram-js/lib/layout/LayoutUtil';
3
+ import { is } from '../../util/ModelUtil';
4
+
5
+ var DEFAULT_POSITION = {
6
+ x: 180,
7
+ y: 160
8
+ };
9
+
10
+ /**
11
+ * Hook into `import.render.start` and create new planes for diagrams with
12
+ * collapsed subprocesses and all dis on the same plane.
13
+ *
14
+ * @param {eventBus} eventBus
15
+ * @param {moddle} moddle
16
+ */
17
+ export default function SubprocessCompatibility(eventBus, moddle) {
18
+ this._eventBus = eventBus;
19
+ this._moddle = moddle;
20
+
21
+ var self = this;
22
+
23
+ eventBus.on('import.render.start', 1500, function(e, context) {
24
+ self.handleImport(context.definitions);
25
+ });
26
+ }
27
+
28
+ SubprocessCompatibility.prototype.handleImport = function(definitions) {
29
+ if (!definitions.diagrams) {
30
+ return;
31
+ }
32
+
33
+ var self = this;
34
+ this._definitions = definitions;
35
+ this._processToDiagramMap = {};
36
+
37
+ definitions.diagrams.forEach(function(diagram) {
38
+ if (!diagram.plane || !diagram.plane.bpmnElement) {
39
+ return;
40
+ }
41
+
42
+ self._processToDiagramMap[diagram.plane.bpmnElement.id] = diagram;
43
+ });
44
+
45
+ var newDiagrams = [];
46
+ definitions.diagrams.forEach(function(diagram) {
47
+ var createdDiagrams = self.createNewDiagrams(diagram.plane);
48
+ Array.prototype.push.apply(newDiagrams, createdDiagrams);
49
+ });
50
+
51
+ newDiagrams.forEach(function(diagram) {
52
+ self.movePlaneElementsToOrigin(diagram.plane);
53
+ });
54
+ };
55
+
56
+
57
+ /**
58
+ * Moves all DI elements from collapsed subprocesses to a new plane.
59
+ *
60
+ * @param {Object} plane
61
+ * @return {Array} new diagrams created for the collapsed subprocesses
62
+ */
63
+ SubprocessCompatibility.prototype.createNewDiagrams = function(plane) {
64
+ var self = this;
65
+
66
+ var collapsedElements = [];
67
+ var elementsToMove = [];
68
+
69
+ plane.get('planeElement').forEach(function(diElement) {
70
+ var bo = diElement.bpmnElement;
71
+ var parent = bo.$parent;
72
+
73
+ if (is(bo, 'bpmn:SubProcess') && !diElement.isExpanded) {
74
+ collapsedElements.push(bo);
75
+ }
76
+
77
+ if (is(parent, 'bpmn:SubProcess') && parent !== plane.bpmnElement) {
78
+
79
+ // don't change the array while we iterate over it
80
+ elementsToMove.push({ diElement: diElement, parent: parent });
81
+ }
82
+ });
83
+
84
+ var newDiagrams = [];
85
+
86
+ elementsToMove.forEach(function(element) {
87
+ var diElement = element.diElement;
88
+ var parent = element.parent;
89
+
90
+ // parent is expanded, get nearest collapsed parent
91
+ while (parent && !collapsedElements.includes(parent)) {
92
+ parent = parent.$parent;
93
+ }
94
+
95
+ // false positive, all parents are expanded
96
+ if (!parent) {
97
+ return;
98
+ }
99
+
100
+ var diagram = self._processToDiagramMap[parent.id];
101
+ if (!diagram) {
102
+ diagram = self.createDiagram(parent);
103
+ self._processToDiagramMap[parent.id] = diagram;
104
+ newDiagrams.push(diagram);
105
+ }
106
+
107
+ self.moveToDiPlane(diElement, diagram.plane);
108
+ });
109
+
110
+ return newDiagrams;
111
+ };
112
+
113
+ SubprocessCompatibility.prototype.movePlaneElementsToOrigin = function(plane) {
114
+ var elements = plane.get('planeElement');
115
+
116
+ // get bounding box of all elements
117
+ var planeBounds = getPlaneBounds(plane);
118
+
119
+ var offset = {
120
+ x: planeBounds.x - DEFAULT_POSITION.x,
121
+ y: planeBounds.y - DEFAULT_POSITION.y
122
+ };
123
+
124
+ elements.forEach(function(diElement) {
125
+ if (diElement.waypoint) {
126
+ diElement.waypoint.forEach(function(waypoint) {
127
+ waypoint.x = waypoint.x - offset.x;
128
+ waypoint.y = waypoint.y - offset.y;
129
+ });
130
+ } else if (diElement.bounds) {
131
+ diElement.bounds.x = diElement.bounds.x - offset.x;
132
+ diElement.bounds.y = diElement.bounds.y - offset.y;
133
+ }
134
+ });
135
+ };
136
+
137
+
138
+ SubprocessCompatibility.prototype.moveToDiPlane = function(diElement, newPlane) {
139
+ var containingDiagram = findRootDiagram(diElement);
140
+
141
+ // remove DI from old Plane and add it to the new one
142
+ var parentPlaneElement = containingDiagram.plane.get('planeElement');
143
+ parentPlaneElement.splice(parentPlaneElement.indexOf(diElement), 1);
144
+ newPlane.get('planeElement').push(diElement);
145
+ };
146
+
147
+
148
+ SubprocessCompatibility.prototype.createDiagram = function(bo) {
149
+ var plane = this._moddle.create('bpmndi:BPMNPlane', { bpmnElement: bo });
150
+ var diagram = this._moddle.create('bpmndi:BPMNDiagram', {
151
+ plane: plane
152
+ });
153
+ plane.$parent = diagram;
154
+ plane.bpmnElement = bo;
155
+ diagram.$parent = this._definitions;
156
+ this._definitions.diagrams.push(diagram);
157
+ return diagram;
158
+ };
159
+
160
+ SubprocessCompatibility.$inject = [ 'eventBus', 'moddle' ];
161
+
162
+
163
+ // helpers
164
+
165
+ function findRootDiagram(element) {
166
+ if (is(element, 'bpmndi:BPMNDiagram')) {
167
+ return element;
168
+ } else {
169
+ return findRootDiagram(element.$parent);
170
+ }
171
+ }
172
+
173
+ function getPlaneBounds(plane) {
174
+ var planeTrbl = {
175
+ top: Infinity,
176
+ right: -Infinity,
177
+ bottom: -Infinity,
178
+ left: Infinity
179
+ };
180
+
181
+ plane.planeElement.forEach(function(element) {
182
+ if (!element.bounds) {
183
+ return;
184
+ }
185
+
186
+ var trbl = asTRBL(element.bounds);
187
+
188
+ planeTrbl.top = Math.min(trbl.top, planeTrbl.top);
189
+ planeTrbl.left = Math.min(trbl.left, planeTrbl.left);
190
+ });
191
+
192
+ return asBounds(planeTrbl);
193
+ }
@@ -0,0 +1,14 @@
1
+ import OverlaysModule from 'diagram-js/lib/features/overlays';
2
+ import ChangeSupportModule from 'diagram-js/lib/features/change-support';
3
+
4
+ import DrilldownOverlays from './DrilldownOverlays';
5
+ import DrilldownCentering from './DrilldownCentering';
6
+ import SubprocessCompatibility from './SubprocessCompatibility';
7
+
8
+ export default {
9
+ __depends__: [ OverlaysModule, ChangeSupportModule ],
10
+ __init__: [ 'drilldownOverlays', 'drilldownCentering', 'subprocessCompatibility'],
11
+ drilldownOverlays: [ 'type', DrilldownOverlays ],
12
+ drilldownCentering: [ 'type', DrilldownCentering ],
13
+ subprocessCompatibility: [ 'type', SubprocessCompatibility ]
14
+ };
@@ -10,8 +10,6 @@ import {
10
10
  } from '../util/LabelUtil';
11
11
 
12
12
  import {
13
- asBounds,
14
- asTRBL,
15
13
  getMid
16
14
  } from 'diagram-js/lib/layout/LayoutUtil';
17
15
 
@@ -50,32 +48,6 @@ function getWaypoints(di, source, target) {
50
48
  });
51
49
  }
52
50
 
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
-
79
51
  function notYetDrawn(translate, semantic, refSemantic, property) {
80
52
  return new Error(translate('element {element} referenced by {referenced}#{property} not yet drawn', {
81
53
  element: elementToString(refSemantic),
@@ -130,39 +102,18 @@ BpmnImporter.prototype.add = function(semantic, di, parentElement) {
130
102
 
131
103
  // ROOT ELEMENT
132
104
  // handle the special case that we deal with a
133
- // invisible root element (process or collaboration)
105
+ // invisible root element (process, subprocess or collaboration)
134
106
  if (is(di, 'bpmndi:BPMNPlane')) {
135
107
 
108
+ // add a virtual element (not being drawn)
109
+ element = this._elementFactory.createRoot(elementData(semantic, di));
110
+
111
+ // for subprocesses, the id is already defined on the collapsed shape
136
112
  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;
156
-
157
- this._canvas.addShape(element, plane.rootElement);
113
+ element.id = element.id + '_plane';
158
114
  }
159
- else {
160
-
161
- // add a virtual element (not being drawn)
162
- element = this._elementFactory.createRoot(elementData(semantic, di));
163
115
 
164
- this._canvas.createPlane(semantic.id, element);
165
- }
116
+ this._canvas.createPlane(semantic.id, element);
166
117
  }
167
118
 
168
119
  // SHAPE
@@ -173,7 +124,7 @@ BpmnImporter.prototype.add = function(semantic, di, parentElement) {
173
124
 
174
125
  hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
175
126
 
176
- bounds = di.bounds;
127
+ var bounds = di.bounds;
177
128
 
178
129
  element = this._elementFactory.createShape(elementData(semantic, di, {
179
130
  collapsed: collapsed,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-js",
3
- "version": "9.0.0-subprocesses.1",
3
+ "version": "9.0.0-subprocesses.2",
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.6.0",
103
+ "diagram-js": "^7.6.1",
104
104
  "diagram-js-direct-editing": "^1.6.3",
105
105
  "ids": "^1.0.0",
106
106
  "inherits": "^2.0.4",
@@ -256,12 +256,7 @@ export function createViewer(container, viewerInstance, xml, diagramId) {
256
256
 
257
257
  clearBpmnJS();
258
258
 
259
- var viewer = new viewerInstance({
260
- container: container,
261
- canvas: {
262
- deferUpdate: false
263
- }
264
- });
259
+ var viewer = new viewerInstance({ container: container });
265
260
 
266
261
  setBpmnJS(viewer);
267
262
 
@@ -1,135 +0,0 @@
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
- };