bpmn-js 8.8.2 → 9.0.0-subprocesses.3

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/assets/bpmn-js.css +79 -0
  3. package/dist/assets/diagram-js.css +82 -78
  4. package/dist/bpmn-modeler.development.js +929 -502
  5. package/dist/bpmn-modeler.production.min.js +7 -6
  6. package/dist/bpmn-navigated-viewer.development.js +20574 -19973
  7. package/dist/bpmn-navigated-viewer.production.min.js +22 -20
  8. package/dist/bpmn-viewer.development.js +19775 -19174
  9. package/dist/bpmn-viewer.production.min.js +22 -20
  10. package/lib/BaseViewer.js +0 -13
  11. package/lib/Viewer.js +3 -1
  12. package/lib/draw/BpmnRenderUtil.js +6 -4
  13. package/lib/features/context-pad/ContextPadProvider.js +1 -1
  14. package/lib/features/copy-paste/BpmnCopyPaste.js +13 -13
  15. package/lib/features/di-ordering/BpmnDiOrdering.js +2 -3
  16. package/lib/features/drilldown/DrilldownCentering.js +41 -0
  17. package/lib/features/drilldown/DrilldownOverlays.js +110 -0
  18. package/lib/features/drilldown/SubprocessCompatibility.js +193 -0
  19. package/lib/features/drilldown/index.js +14 -0
  20. package/lib/features/label-editing/LabelEditingPreview.js +3 -3
  21. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +2 -1
  22. package/lib/features/modeling/BpmnFactory.js +8 -8
  23. package/lib/features/modeling/BpmnUpdater.js +35 -27
  24. package/lib/features/modeling/ElementFactory.js +60 -37
  25. package/lib/features/modeling/behavior/DataStoreBehavior.js +3 -1
  26. package/lib/features/modeling/behavior/IsHorizontalFix.js +7 -4
  27. package/lib/features/modeling/behavior/LabelBehavior.js +8 -7
  28. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +6 -6
  29. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +8 -6
  30. package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +19 -12
  31. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.js +5 -3
  32. package/lib/features/palette/PaletteProvider.js +3 -1
  33. package/lib/features/popup-menu/ReplaceMenuProvider.js +5 -5
  34. package/lib/features/popup-menu/util/TypeUtil.js +1 -1
  35. package/lib/features/replace/BpmnReplace.js +29 -29
  36. package/lib/import/BpmnImporter.js +27 -22
  37. package/lib/import/BpmnTreeWalker.js +19 -17
  38. package/lib/import/Importer.js +17 -6
  39. package/lib/util/CompatibilityUtil.js +21 -1
  40. package/lib/util/DiUtil.js +10 -3
  41. package/lib/util/LabelUtil.js +2 -3
  42. package/lib/util/ModelUtil.js +11 -0
  43. package/package.json +2 -2
  44. package/test/matchers/BoundsMatchers.js +10 -10
  45. package/test/matchers/ConnectionMatchers.js +5 -5
@@ -99,7 +99,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
99
99
  if (is(businessObject, 'bpmn:Participant')) {
100
100
 
101
101
  entries = filter(replaceOptions.PARTICIPANT, function(entry) {
102
- return isExpanded(businessObject) !== entry.target.isExpanded;
102
+ return isExpanded(element) !== entry.target.isExpanded;
103
103
  });
104
104
 
105
105
  return this._createEntries(element, entries);
@@ -195,7 +195,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
195
195
  }
196
196
 
197
197
  // expanded event sub processes
198
- if (isEventSubProcess(businessObject) && isExpanded(businessObject)) {
198
+ if (isEventSubProcess(businessObject) && isExpanded(element)) {
199
199
 
200
200
  entries = filter(replaceOptions.EVENT_SUB_PROCESS, differentType);
201
201
 
@@ -203,7 +203,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
203
203
  }
204
204
 
205
205
  // expanded sub processes
206
- if (is(businessObject, 'bpmn:SubProcess') && isExpanded(businessObject)) {
206
+ if (is(businessObject, 'bpmn:SubProcess') && isExpanded(element)) {
207
207
 
208
208
  entries = filter(replaceOptions.SUBPROCESS_EXPANDED, differentType);
209
209
 
@@ -211,7 +211,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
211
211
  }
212
212
 
213
213
  // collapsed ad hoc sub processes
214
- if (is(businessObject, 'bpmn:AdHocSubProcess') && !isExpanded(businessObject)) {
214
+ if (is(businessObject, 'bpmn:AdHocSubProcess') && !isExpanded(element)) {
215
215
 
216
216
  entries = filter(replaceOptions.TASK, function(entry) {
217
217
 
@@ -237,7 +237,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
237
237
  entries = filter(replaceOptions.TASK, differentType);
238
238
 
239
239
  // collapsed SubProcess can not be replaced with itself
240
- if (is(businessObject, 'bpmn:SubProcess') && !isExpanded(businessObject)) {
240
+ if (is(businessObject, 'bpmn:SubProcess') && !isExpanded(element)) {
241
241
  entries = filter(entries, function(entry) {
242
242
  return entry.label !== 'Sub Process (collapsed)';
243
243
  });
@@ -36,7 +36,7 @@ export function isDifferentType(element) {
36
36
 
37
37
  var isExpandedEqual = (
38
38
  target.isExpanded === undefined ||
39
- target.isExpanded === isExpanded(businessObject)
39
+ target.isExpanded === isExpanded(element)
40
40
  );
41
41
 
42
42
  return !isTypeEqual || !isEventDefinitionEqual || !isTriggeredByEventEqual || !isExpandedEqual;
@@ -36,6 +36,7 @@ function copyProperties(source, target, properties) {
36
36
  });
37
37
  }
38
38
 
39
+
39
40
  var CUSTOM_PROPERTIES = [
40
41
  'cancelActivity',
41
42
  'instantiate',
@@ -44,8 +45,10 @@ var CUSTOM_PROPERTIES = [
44
45
  'isInterrupting'
45
46
  ];
46
47
 
47
-
48
- function toggeling(element, target) {
48
+ /**
49
+ * Check if element should be collapsed or expanded.
50
+ */
51
+ function shouldToggleCollapsed(element, targetElement) {
49
52
 
50
53
  var oldCollapsed = (
51
54
  element && has(element, 'collapsed') ? element.collapsed : !isExpanded(element)
@@ -53,11 +56,11 @@ function toggeling(element, target) {
53
56
 
54
57
  var targetCollapsed;
55
58
 
56
- if (target && (has(target, 'collapsed') || has(target, 'isExpanded'))) {
59
+ if (targetElement && (has(targetElement, 'collapsed') || has(targetElement, 'isExpanded'))) {
57
60
 
58
61
  // property is explicitly set so use it
59
62
  targetCollapsed = (
60
- has(target, 'collapsed') ? target.collapsed : !target.isExpanded
63
+ has(targetElement, 'collapsed') ? targetElement.collapsed : !targetElement.isExpanded
61
64
  );
62
65
  } else {
63
66
 
@@ -66,7 +69,6 @@ function toggeling(element, target) {
66
69
  }
67
70
 
68
71
  if (oldCollapsed !== targetCollapsed) {
69
- element.collapsed = oldCollapsed;
70
72
  return true;
71
73
  }
72
74
 
@@ -74,7 +76,6 @@ function toggeling(element, target) {
74
76
  }
75
77
 
76
78
 
77
-
78
79
  /**
79
80
  * This module takes care of replacing BPMN elements
80
81
  */
@@ -105,15 +106,13 @@ export default function BpmnReplace(
105
106
  var type = target.type,
106
107
  oldBusinessObject = element.businessObject;
107
108
 
108
- if (isSubProcess(oldBusinessObject)) {
109
- if (type === 'bpmn:SubProcess') {
110
- if (toggeling(element, target)) {
109
+ if (isSubProcess(oldBusinessObject) && type === 'bpmn:SubProcess') {
110
+ if (shouldToggleCollapsed(element, target)) {
111
111
 
112
- // expanding or collapsing process
113
- modeling.toggleCollapse(element);
112
+ // expanding or collapsing process
113
+ modeling.toggleCollapse(element);
114
114
 
115
- return element;
116
- }
115
+ return element;
117
116
  }
118
117
  }
119
118
 
@@ -121,9 +120,20 @@ export default function BpmnReplace(
121
120
 
122
121
  var newElement = {
123
122
  type: type,
124
- businessObject: newBusinessObject
123
+ businessObject: newBusinessObject,
125
124
  };
126
125
 
126
+ newElement.di = {};
127
+
128
+ // colors will be set to DI
129
+ copyProperties(element.di, newElement.di, [
130
+ 'fill',
131
+ 'stroke',
132
+ 'background-color',
133
+ 'border-color',
134
+ 'color'
135
+ ]);
136
+
127
137
  var elementProps = getPropertyNames(oldBusinessObject.$descriptor),
128
138
  newElementProps = getPropertyNames(newBusinessObject.$descriptor, true),
129
139
  copyProps = intersection(elementProps, newElementProps);
@@ -183,7 +193,7 @@ export default function BpmnReplace(
183
193
  if (isSubProcess(oldBusinessObject)) {
184
194
 
185
195
  // no toggeling, so keep old state
186
- newElement.isExpanded = isExpanded(oldBusinessObject);
196
+ newElement.isExpanded = isExpanded(element);
187
197
  }
188
198
 
189
199
  // else if property is explicitly set, use it
@@ -194,7 +204,7 @@ export default function BpmnReplace(
194
204
  // TODO: need also to respect min/max Size
195
205
  // copy size, from an expanded subprocess to an expanded alternative subprocess
196
206
  // except bpmn:Task, because Task is always expanded
197
- if ((isExpanded(oldBusinessObject) && !is(oldBusinessObject, 'bpmn:Task')) && newElement.isExpanded) {
207
+ if ((isExpanded(element) && !is(oldBusinessObject, 'bpmn:Task')) && newElement.isExpanded) {
198
208
  newElement.width = element.width;
199
209
  newElement.height = element.height;
200
210
  }
@@ -219,12 +229,12 @@ export default function BpmnReplace(
219
229
 
220
230
  // apply same width and default height
221
231
  newElement.width = element.width;
222
- newElement.height = elementFactory._getDefaultSize(newBusinessObject).height;
232
+ newElement.height = elementFactory.getDefaultSize(newElement).height;
223
233
  }
224
234
 
225
235
  if (!rules.allowed('shape.resize', { shape: newBusinessObject })) {
226
- newElement.height = elementFactory._getDefaultSize(newBusinessObject).height;
227
- newElement.width = elementFactory._getDefaultSize(newBusinessObject).width;
236
+ newElement.height = elementFactory.getDefaultSize(newElement).height;
237
+ newElement.width = elementFactory.getDefaultSize(newElement).width;
228
238
  }
229
239
 
230
240
  newBusinessObject.name = oldBusinessObject.name;
@@ -262,16 +272,6 @@ export default function BpmnReplace(
262
272
  newElement.x = element.x + (element.width - newElement.width) / 2;
263
273
  }
264
274
 
265
- newElement.di = {};
266
-
267
- // colors will be set to DI
268
- copyProperties(oldBusinessObject.di, newElement.di, [
269
- 'fill',
270
- 'stroke',
271
- 'background-color',
272
- 'border-color',
273
- 'color'
274
- ]);
275
275
 
276
276
  newElement = replace.replaceElement(element, newElement, hints);
277
277
 
@@ -26,17 +26,18 @@ import {
26
26
  } from './Util';
27
27
 
28
28
 
29
- function elementData(semantic, attrs) {
29
+ function elementData(semantic, di, attrs) {
30
30
  return assign({
31
31
  id: semantic.id,
32
32
  type: semantic.$type,
33
- businessObject: semantic
33
+ businessObject: semantic,
34
+ di: di
34
35
  }, attrs);
35
36
  }
36
37
 
37
- function getWaypoints(bo, source, target) {
38
+ function getWaypoints(di, source, target) {
38
39
 
39
- var waypoints = bo.di.waypoint;
40
+ var waypoints = di.waypoint;
40
41
 
41
42
  if (!waypoints || waypoints.length < 2) {
42
43
  return [ getMid(source), getMid(target) ];
@@ -92,10 +93,8 @@ BpmnImporter.$inject = [
92
93
  * Add bpmn element (semantic) to the canvas onto the
93
94
  * specified parent shape.
94
95
  */
95
- BpmnImporter.prototype.add = function(semantic, parentElement) {
96
-
97
- var di = semantic.di,
98
- element,
96
+ BpmnImporter.prototype.add = function(semantic, di, parentElement) {
97
+ var element,
99
98
  translate = this._translate,
100
99
  hidden;
101
100
 
@@ -103,25 +102,31 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
103
102
 
104
103
  // ROOT ELEMENT
105
104
  // handle the special case that we deal with a
106
- // invisible root element (process or collaboration)
105
+ // invisible root element (process, subprocess or collaboration)
107
106
  if (is(di, 'bpmndi:BPMNPlane')) {
108
107
 
109
108
  // add a virtual element (not being drawn)
110
- element = this._elementFactory.createRoot(elementData(semantic));
109
+ element = this._elementFactory.createRoot(elementData(semantic, di));
111
110
 
112
- this._canvas.setRootElement(element);
111
+ // for subprocesses, the id is already defined on the collapsed shape
112
+ if (is(semantic, 'bpmn:SubProcess')) {
113
+ element.id = element.id + '_plane';
114
+ }
115
+
116
+ this._canvas.createPlane(semantic.id, element);
113
117
  }
114
118
 
115
119
  // SHAPE
116
120
  else if (is(di, 'bpmndi:BPMNShape')) {
117
121
 
118
- var collapsed = !isExpanded(semantic),
122
+ var collapsed = !isExpanded(semantic, di),
119
123
  isFrame = isFrameElement(semantic);
124
+
120
125
  hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
121
126
 
122
- var bounds = semantic.di.bounds;
127
+ var bounds = di.bounds;
123
128
 
124
- element = this._elementFactory.createShape(elementData(semantic, {
129
+ element = this._elementFactory.createShape(elementData(semantic, di, {
125
130
  collapsed: collapsed,
126
131
  hidden: hidden,
127
132
  x: Math.round(bounds.x),
@@ -144,7 +149,7 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
144
149
 
145
150
  // check whether data store is inside our outside of its semantic parent
146
151
  if (!isPointInsideBBox(parentElement, getMid(bounds))) {
147
- parentElement = this._canvas.getRootElement();
152
+ parentElement = this._canvas.findPlane(parentElement).rootElement;
148
153
  }
149
154
  }
150
155
 
@@ -159,11 +164,11 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
159
164
 
160
165
  hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
161
166
 
162
- element = this._elementFactory.createConnection(elementData(semantic, {
167
+ element = this._elementFactory.createConnection(elementData(semantic, di, {
163
168
  hidden: hidden,
164
169
  source: source,
165
170
  target: target,
166
- waypoints: getWaypoints(semantic, source, target)
171
+ waypoints: getWaypoints(di, source, target)
167
172
  }));
168
173
 
169
174
  if (is(semantic, 'bpmn:DataAssociation')) {
@@ -172,7 +177,7 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
172
177
  // are rendered correctly across different "hacks" people
173
178
  // love to model such as cross participant / sub process
174
179
  // associations
175
- parentElement = null;
180
+ parentElement = this._canvas.findPlane(parentElement).rootElement;
176
181
  }
177
182
 
178
183
  // insert sequence flows behind other flow nodes (cf. #727)
@@ -190,7 +195,7 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
190
195
 
191
196
  // (optional) LABEL
192
197
  if (isLabelExternal(semantic) && getLabel(element)) {
193
- this.addLabel(semantic, element);
198
+ this.addLabel(semantic, di, element);
194
199
  }
195
200
 
196
201
 
@@ -239,12 +244,12 @@ BpmnImporter.prototype._attachBoundary = function(boundarySemantic, boundaryElem
239
244
  /**
240
245
  * add label for an element
241
246
  */
242
- BpmnImporter.prototype.addLabel = function(semantic, element) {
247
+ BpmnImporter.prototype.addLabel = function(semantic, di, element) {
243
248
  var bounds,
244
249
  text,
245
250
  label;
246
251
 
247
- bounds = getExternalLabelBounds(semantic, element);
252
+ bounds = getExternalLabelBounds(di, element);
248
253
 
249
254
  text = getLabel(element);
250
255
 
@@ -254,7 +259,7 @@ BpmnImporter.prototype.addLabel = function(semantic, element) {
254
259
  bounds = this._textRenderer.getExternalLabelBounds(bounds, text);
255
260
  }
256
261
 
257
- label = this._elementFactory.createLabel(elementData(semantic, {
262
+ label = this._elementFactory.createLabel(elementData(semantic, di, {
258
263
  id: semantic.id + '_label',
259
264
  labelTarget: element,
260
265
  type: 'label',
@@ -4,16 +4,14 @@ import {
4
4
  forEach
5
5
  } from 'min-dash';
6
6
 
7
- import Refs from 'object-refs';
8
-
9
7
  import {
10
8
  elementToString
11
9
  } from './Util';
12
10
 
13
- var diRefs = new Refs(
14
- { name: 'bpmnElement', enumerable: true },
15
- { name: 'di', configurable: true }
16
- );
11
+ import {
12
+ ensureCompatDiRef
13
+ } from '../util/CompatibilityUtil';
14
+
17
15
 
18
16
  /**
19
17
  * Returns true if an element has the given meta-model type
@@ -48,6 +46,8 @@ export default function BpmnTreeWalker(handler, translate) {
48
46
  // prerequisites are drawn
49
47
  var deferred = [];
50
48
 
49
+ var diMap = {};
50
+
51
51
  // Helpers //////////////////////
52
52
 
53
53
  function contextual(fn, ctx) {
@@ -76,17 +76,17 @@ export default function BpmnTreeWalker(handler, translate) {
76
76
  }
77
77
 
78
78
  // call handler
79
- return handler.element(element, ctx);
79
+ return handler.element(element, diMap[element.id], ctx);
80
80
  }
81
81
 
82
82
  function visitRoot(element, diagram) {
83
- return handler.root(element, diagram);
83
+ return handler.root(element, diMap[element.id], diagram);
84
84
  }
85
85
 
86
86
  function visitIfDi(element, ctx) {
87
87
 
88
88
  try {
89
- var gfx = element.di && visit(element, ctx);
89
+ var gfx = diMap[element.id] && visit(element, ctx);
90
90
 
91
91
  handled(element);
92
92
 
@@ -109,7 +109,7 @@ export default function BpmnTreeWalker(handler, translate) {
109
109
  var bpmnElement = di.bpmnElement;
110
110
 
111
111
  if (bpmnElement) {
112
- if (bpmnElement.di) {
112
+ if (diMap[bpmnElement.id]) {
113
113
  logError(
114
114
  translate('multiple DI elements defined for {element}', {
115
115
  element: elementToString(bpmnElement)
@@ -117,8 +117,9 @@ export default function BpmnTreeWalker(handler, translate) {
117
117
  { element: bpmnElement }
118
118
  );
119
119
  } else {
120
- diRefs.bind(bpmnElement, 'di');
121
- bpmnElement.di = di;
120
+ diMap[bpmnElement.id] = di;
121
+
122
+ ensureCompatDiRef(bpmnElement);
122
123
  }
123
124
  } else {
124
125
  logError(
@@ -175,6 +176,7 @@ export default function BpmnTreeWalker(handler, translate) {
175
176
  }
176
177
 
177
178
  // load DI from selected diagram only
179
+ diMap = {};
178
180
  handleDiagram(diagram);
179
181
 
180
182
 
@@ -214,7 +216,7 @@ export default function BpmnTreeWalker(handler, translate) {
214
216
 
215
217
  var ctx = visitRoot(rootElement, plane);
216
218
 
217
- if (is(rootElement, 'bpmn:Process')) {
219
+ if (is(rootElement, 'bpmn:Process') || is(rootElement, 'bpmn:SubProcess')) {
218
220
  handleProcess(rootElement, ctx);
219
221
  } else if (is(rootElement, 'bpmn:Collaboration')) {
220
222
  handleCollaboration(rootElement, ctx);
@@ -427,15 +429,15 @@ export default function BpmnTreeWalker(handler, translate) {
427
429
  }
428
430
  }
429
431
 
430
- function handleCollaboration(collaboration) {
432
+ function handleCollaboration(collaboration, context) {
431
433
 
432
- forEach(collaboration.participants, contextual(handleParticipant));
434
+ forEach(collaboration.participants, contextual(handleParticipant, context));
433
435
 
434
- handleArtifacts(collaboration.artifacts);
436
+ handleArtifacts(collaboration.artifacts, context);
435
437
 
436
438
  // handle message flows latest in the process
437
439
  deferred.push(function() {
438
- handleMessageFlows(collaboration.messageFlows);
440
+ handleMessageFlows(collaboration.messageFlows, context);
439
441
  });
440
442
  }
441
443
 
@@ -33,7 +33,8 @@ export function importBpmnDiagram(diagram, definitions, bpmnDiagram) {
33
33
 
34
34
  var importer,
35
35
  eventBus,
36
- translate;
36
+ translate,
37
+ canvas;
37
38
 
38
39
  var error,
39
40
  warnings = [];
@@ -49,12 +50,12 @@ export function importBpmnDiagram(diagram, definitions, bpmnDiagram) {
49
50
 
50
51
  var visitor = {
51
52
 
52
- root: function(element) {
53
- return importer.add(element);
53
+ root: function(element, di) {
54
+ return importer.add(element, di);
54
55
  },
55
56
 
56
- element: function(element, parentShape) {
57
- return importer.add(element, parentShape);
57
+ element: function(element, di, parentShape) {
58
+ return importer.add(element, di, parentShape);
58
59
  },
59
60
 
60
61
  error: function(message, context) {
@@ -66,7 +67,16 @@ export function importBpmnDiagram(diagram, definitions, bpmnDiagram) {
66
67
 
67
68
  // traverse BPMN 2.0 document model,
68
69
  // starting at definitions
69
- walker.handleDefinitions(definitions, bpmnDiagram);
70
+ if (!bpmnDiagram && definitions.diagrams) {
71
+ for (var i = 0; i < definitions.diagrams.length; i++) {
72
+ walker.handleDefinitions(definitions, definitions.diagrams[i]);
73
+ }
74
+ } else {
75
+ walker.handleDefinitions(definitions, bpmnDiagram);
76
+ }
77
+
78
+ var mainDiagram = bpmnDiagram || definitions.diagrams[0];
79
+ canvas.setActivePlane(mainDiagram.plane.bpmnElement.id);
70
80
  }
71
81
 
72
82
  return new Promise(function(resolve, reject) {
@@ -74,6 +84,7 @@ export function importBpmnDiagram(diagram, definitions, bpmnDiagram) {
74
84
  importer = diagram.get('bpmnImporter');
75
85
  eventBus = diagram.get('eventBus');
76
86
  translate = diagram.get('translate');
87
+ canvas = diagram.get('canvas');
77
88
 
78
89
  eventBus.fire('import.render.start', { definitions: definitions });
79
90
 
@@ -1,4 +1,7 @@
1
- import { isFunction } from 'min-dash';
1
+ import {
2
+ has,
3
+ isFunction
4
+ } from 'min-dash';
2
5
 
3
6
  // TODO(nikku): remove with future bpmn-js version
4
7
 
@@ -51,3 +54,20 @@ export function wrapForCompatibility(api) {
51
54
  }
52
55
  };
53
56
  }
57
+
58
+
59
+ // TODO(nikku): remove with future bpmn-js version
60
+
61
+ var DI_ERROR_MESSAGE = 'Tried to access di from the businessObject. The di is available through the diagram element only. For more information, see https://github.com/bpmn-io/bpmn-js/issues/1472';
62
+
63
+ export function ensureCompatDiRef(businessObject) {
64
+
65
+ // bpmnElement can have multiple independent DIs
66
+ if (!has(businessObject, 'di')) {
67
+ Object.defineProperty(businessObject, 'di', {
68
+ get: function() {
69
+ throw new Error(DI_ERROR_MESSAGE);
70
+ }
71
+ });
72
+ }
73
+ }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  is,
3
- getBusinessObject
3
+ getBusinessObject,
4
+ getDi
4
5
  } from './ModelUtil';
5
6
 
6
7
  import {
@@ -8,14 +9,20 @@ import {
8
9
  } from 'min-dash';
9
10
 
10
11
 
11
- export function isExpanded(element) {
12
+ export function isExpanded(element, di) {
12
13
 
13
14
  if (is(element, 'bpmn:CallActivity')) {
14
15
  return false;
15
16
  }
16
17
 
17
18
  if (is(element, 'bpmn:SubProcess')) {
18
- return getBusinessObject(element).di && !!getBusinessObject(element).di.isExpanded;
19
+ di = di || getDi(element);
20
+
21
+ if (di && is(di, 'bpmndi:BPMNPlane')) {
22
+ return true;
23
+ }
24
+
25
+ return di && !!di.isExpanded;
19
26
  }
20
27
 
21
28
  if (is(element, 'bpmn:Participant')) {
@@ -116,15 +116,14 @@ export function getExternalLabelMid(element) {
116
116
  * Returns the bounds of an elements label, parsed from the elements DI or
117
117
  * generated from its bounds.
118
118
  *
119
- * @param {BpmnElement} semantic
119
+ * @param {BpmndDi} di
120
120
  * @param {djs.model.Base} element
121
121
  */
122
- export function getExternalLabelBounds(semantic, element) {
122
+ export function getExternalLabelBounds(di, element) {
123
123
 
124
124
  var mid,
125
125
  size,
126
126
  bounds,
127
- di = semantic.di,
128
127
  label = di.label;
129
128
 
130
129
  if (label && label.bounds) {
@@ -22,4 +22,15 @@ export function is(element, type) {
22
22
  */
23
23
  export function getBusinessObject(element) {
24
24
  return (element && element.businessObject) || element;
25
+ }
26
+
27
+ /**
28
+ * Return the di object for a given element.
29
+ *
30
+ * @param {djs.model.Base} element
31
+ *
32
+ * @return {ModdleElement}
33
+ */
34
+ export function getDi(element) {
35
+ return element && element.di;
25
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-js",
3
- "version": "8.8.2",
3
+ "version": "9.0.0-subprocesses.3",
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.5.0",
103
+ "diagram-js": "^7.8.1",
104
104
  "diagram-js-direct-editing": "^1.6.3",
105
105
  "ids": "^1.0.0",
106
106
  "inherits": "^2.0.4",
@@ -3,7 +3,7 @@ import {
3
3
  } from 'min-dash';
4
4
 
5
5
  import {
6
- getBusinessObject
6
+ getDi
7
7
  } from 'lib/util/ModelUtil';
8
8
 
9
9
  var BOUNDS_ATTRS = [ 'x', 'y', 'width', 'height' ],
@@ -82,11 +82,11 @@ export default function(chai, utils) {
82
82
  Assertion.addMethod('diBounds', function(exp) {
83
83
  var obj = this._obj;
84
84
 
85
- var bo = getBusinessObject(obj);
85
+ var di = getDi(obj);
86
86
 
87
- expect(bo).to.have.property('di');
87
+ expect(di).to.exist;
88
88
 
89
- assertBounds(this, bo.id + '#di', getBounds(bo.di), getBounds(exp));
89
+ assertBounds(this, di.id, getBounds(di), getBounds(exp));
90
90
  });
91
91
 
92
92
  /**
@@ -125,11 +125,11 @@ export default function(chai, utils) {
125
125
 
126
126
  var obj = this._obj;
127
127
 
128
- var bo = getBusinessObject(obj);
128
+ var di = getDi(obj);
129
129
 
130
- expect(bo).to.have.property('di');
130
+ expect(di).to.exist;
131
131
 
132
- assertDimensions(this, bo.id + '#di', getDimensions(bo.di), getDimensions(exp));
132
+ assertDimensions(this, di.id, getDimensions(di), getDimensions(exp));
133
133
  });
134
134
 
135
135
 
@@ -169,11 +169,11 @@ export default function(chai, utils) {
169
169
 
170
170
  var obj = this._obj;
171
171
 
172
- var bo = getBusinessObject(obj);
172
+ var di = getDi(obj);
173
173
 
174
- expect(bo).to.have.property('di');
174
+ expect(di).to.exist;
175
175
 
176
- assertPosition(this, bo.id + '#di', getPosition(bo.di), getPosition(exp));
176
+ assertPosition(this, di.id, getPosition(di), getPosition(exp));
177
177
  });
178
178
 
179
179