bpmn-js 8.9.0 → 9.0.0-alpha.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/assets/bpmn-js.css +113 -0
  3. package/dist/bpmn-modeler.development.js +2600 -991
  4. package/dist/bpmn-modeler.production.min.js +9 -8
  5. package/dist/bpmn-navigated-viewer.development.js +21240 -19985
  6. package/dist/bpmn-navigated-viewer.production.min.js +22 -20
  7. package/dist/bpmn-viewer.development.js +20441 -19186
  8. package/dist/bpmn-viewer.production.min.js +22 -20
  9. package/lib/BaseViewer.js +1 -14
  10. package/lib/Viewer.js +3 -1
  11. package/lib/draw/BpmnRenderUtil.js +6 -4
  12. package/lib/features/auto-resize/BpmnAutoResizeProvider.js +6 -0
  13. package/lib/features/context-pad/ContextPadProvider.js +1 -1
  14. package/lib/features/copy-paste/BpmnCopyPaste.js +14 -13
  15. package/lib/features/di-ordering/BpmnDiOrdering.js +16 -13
  16. package/lib/features/drilldown/DrilldownBreadcrumbs.js +122 -0
  17. package/lib/features/drilldown/DrilldownCentering.js +118 -0
  18. package/lib/features/drilldown/DrilldownOverlayBehavior.js +181 -0
  19. package/lib/features/drilldown/SubprocessCompatibility.js +196 -0
  20. package/lib/features/drilldown/index.js +17 -0
  21. package/lib/features/label-editing/LabelEditingPreview.js +3 -3
  22. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +31 -3
  23. package/lib/features/modeling/BpmnFactory.js +11 -8
  24. package/lib/features/modeling/BpmnUpdater.js +35 -27
  25. package/lib/features/modeling/ElementFactory.js +64 -37
  26. package/lib/features/modeling/behavior/CreateParticipantBehavior.js +59 -84
  27. package/lib/features/modeling/behavior/DataStoreBehavior.js +3 -1
  28. package/lib/features/modeling/behavior/IsHorizontalFix.js +7 -4
  29. package/lib/features/modeling/behavior/LabelBehavior.js +8 -7
  30. package/lib/features/modeling/behavior/SubProcessPlaneBehavior.js +550 -0
  31. package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.js +74 -0
  32. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +6 -6
  33. package/lib/features/modeling/behavior/UnclaimIdBehavior.js +3 -1
  34. package/lib/features/modeling/behavior/index.js +6 -0
  35. package/lib/features/modeling/cmd/SetColorHandler.js +4 -1
  36. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +12 -8
  37. package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +19 -12
  38. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.js +5 -3
  39. package/lib/features/modeling/util/ModelingUtil.js +2 -20
  40. package/lib/features/ordering/BpmnOrderingProvider.js +1 -1
  41. package/lib/features/palette/PaletteProvider.js +3 -1
  42. package/lib/features/popup-menu/ReplaceMenuProvider.js +6 -6
  43. package/lib/features/popup-menu/util/TypeUtil.js +1 -1
  44. package/lib/features/replace/BpmnReplace.js +29 -29
  45. package/lib/import/BpmnImporter.js +33 -22
  46. package/lib/import/BpmnTreeWalker.js +19 -17
  47. package/lib/import/Importer.js +137 -6
  48. package/lib/util/CompatibilityUtil.js +21 -1
  49. package/lib/util/DiUtil.js +10 -3
  50. package/lib/util/DrilldownUtil.js +66 -0
  51. package/lib/util/LabelUtil.js +2 -3
  52. package/lib/util/ModelUtil.js +30 -0
  53. package/package.json +2 -2
  54. package/test/matchers/BoundsMatchers.js +10 -10
  55. package/test/matchers/ConnectionMatchers.js +5 -5
package/lib/BaseViewer.js CHANGED
@@ -439,7 +439,7 @@ BaseViewer.prototype.saveSVG = wrapForCompatibility(function saveSVG(options) {
439
439
  try {
440
440
  var canvas = self.get('canvas');
441
441
 
442
- var contentNode = canvas.getDefaultLayer(),
442
+ var contentNode = canvas.getActiveLayer(),
443
443
  defsNode = domQuery('defs', canvas._svg);
444
444
 
445
445
  var contents = innerSVG(contentNode),
@@ -528,19 +528,6 @@ BaseViewer.prototype.clear = function() {
528
528
  return;
529
529
  }
530
530
 
531
- // remove businessObject#di binding
532
- //
533
- // this is necessary, as we establish the bindings
534
- // in the BpmnTreeWalker (and assume none are given
535
- // on reimport)
536
- this.get('elementRegistry').forEach(function(element) {
537
- var bo = element.businessObject;
538
-
539
- if (bo && bo.di) {
540
- delete bo.di;
541
- }
542
- });
543
-
544
531
  // remove drawn elements
545
532
  Diagram.prototype.clear.call(this);
546
533
  };
package/lib/Viewer.js CHANGED
@@ -4,6 +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 DrilldownModdule from './features/drilldown';
7
8
 
8
9
  import BaseViewer from './BaseViewer';
9
10
 
@@ -66,7 +67,8 @@ Viewer.prototype._modules = [
66
67
  CoreModule,
67
68
  TranslateModule,
68
69
  SelectionModule,
69
- OverlaysModule
70
+ OverlaysModule,
71
+ DrilldownModdule
70
72
  ];
71
73
 
72
74
  // default moddle extensions the viewer is composed of
@@ -3,10 +3,16 @@ import {
3
3
  some
4
4
  } from 'min-dash';
5
5
 
6
+ import {
7
+ getDi
8
+ } from '../util/ModelUtil';
9
+
6
10
  import {
7
11
  componentsToPath
8
12
  } from 'diagram-js/lib/util/RenderUtil';
9
13
 
14
+ // re-export getDi for compatibility
15
+ export { getDi };
10
16
 
11
17
  // element utils //////////////////////
12
18
 
@@ -42,10 +48,6 @@ export function isCollection(element) {
42
48
  return element.isCollection || (dataObject && dataObject.isCollection);
43
49
  }
44
50
 
45
- export function getDi(element) {
46
- return element.businessObject.di;
47
- }
48
-
49
51
  export function getSemantic(element) {
50
52
  return element.businessObject;
51
53
  }
@@ -33,6 +33,12 @@ BpmnAutoResizeProvider.$inject = [
33
33
  */
34
34
  BpmnAutoResizeProvider.prototype.canResize = function(elements, target) {
35
35
 
36
+ // do not resize plane elements:
37
+ // root elements, collapsed sub-processes
38
+ if (is(target.di, 'bpmndi:BPMNPlane')) {
39
+ return false;
40
+ }
41
+
36
42
  if (!is(target, 'bpmn:Participant') && !is(target, 'bpmn:Lane') && !(is(target, 'bpmn:SubProcess'))) {
37
43
  return false;
38
44
  }
@@ -197,7 +197,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
197
197
  }
198
198
 
199
199
 
200
- if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded(businessObject)) {
200
+ if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded(element)) {
201
201
 
202
202
  var childLanes = getChildLanes(element);
203
203
 
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  getBusinessObject,
3
+ getDi,
3
4
  is
4
5
  } from '../../util/ModelUtil';
5
6
 
@@ -45,23 +46,13 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
45
46
  element = context.element;
46
47
 
47
48
  var businessObject = descriptor.oldBusinessObject = getBusinessObject(element);
49
+ var di = descriptor.oldDi = getDi(element);
48
50
 
49
51
  descriptor.type = element.type;
50
52
 
51
53
  copyProperties(businessObject, descriptor, 'name');
52
54
 
53
- descriptor.di = {};
54
-
55
- // colors will be set to DI
56
- copyProperties(businessObject.di, descriptor.di, [
57
- 'fill',
58
- 'stroke',
59
- 'background-color',
60
- 'border-color',
61
- 'color'
62
- ]);
63
-
64
- copyProperties(businessObject.di, descriptor, 'isExpanded');
55
+ copyProperties(di, descriptor, 'isExpanded');
65
56
 
66
57
  if (isLabel(descriptor)) {
67
58
  return descriptor;
@@ -135,11 +126,13 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
135
126
  var cache = context.cache,
136
127
  descriptor = context.descriptor,
137
128
  oldBusinessObject = descriptor.oldBusinessObject,
138
- newBusinessObject;
129
+ oldDi = descriptor.oldDi,
130
+ newBusinessObject, newDi;
139
131
 
140
132
  // do NOT copy business object if external label
141
133
  if (isLabel(descriptor)) {
142
134
  descriptor.businessObject = getBusinessObject(cache[ descriptor.labelTarget ]);
135
+ descriptor.di = getDi(cache[ descriptor.labelTarget ]);
143
136
 
144
137
  return;
145
138
  }
@@ -151,6 +144,14 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
151
144
  newBusinessObject
152
145
  );
153
146
 
147
+ newDi = bpmnFactory.create(oldDi.$type);
148
+ newDi.bpmnElement = newBusinessObject;
149
+
150
+ descriptor.di = moddleCopy.copyElement(
151
+ oldDi,
152
+ newDi
153
+ );
154
+
154
155
  // resolve references e.g. default sequence flow
155
156
  resolveReferences(descriptor, cache);
156
157
 
@@ -1,8 +1,8 @@
1
- import { getDi } from '../../draw/BpmnRenderUtil';
2
- import { getBusinessObject } from '../../util/ModelUtil';
1
+ import { getDi } from '../../util/ModelUtil';
3
2
 
4
3
  import {
5
4
  filter,
5
+ forEach,
6
6
  map
7
7
  } from 'min-dash';
8
8
 
@@ -16,21 +16,24 @@ export default function BpmnDiOrdering(eventBus, canvas) {
16
16
  eventBus.on('saveXML.start', HIGH_PRIORITY, orderDi);
17
17
 
18
18
  function orderDi() {
19
- var root = canvas.getRootElement(),
20
- rootDi = getBusinessObject(root).di,
21
- elements,
22
- diElements;
19
+ var rootElements = canvas.getRootElements();
23
20
 
24
- elements = selfAndAllChildren([ root ], false);
21
+ forEach(rootElements, function(root) {
22
+ var rootDi = getDi(root),
23
+ elements,
24
+ diElements;
25
25
 
26
- // only bpmndi:Shape and bpmndi:Edge can be direct children of bpmndi:Plane
27
- elements = filter(elements, function(element) {
28
- return element !== root && !element.labelTarget;
29
- });
26
+ elements = selfAndAllChildren([ root ], false);
27
+
28
+ // only bpmndi:Shape and bpmndi:Edge can be direct children of bpmndi:Plane
29
+ elements = filter(elements, function(element) {
30
+ return element !== root && !element.labelTarget;
31
+ });
30
32
 
31
- diElements = map(elements, getDi);
33
+ diElements = map(elements, getDi);
32
34
 
33
- rootDi.set('planeElement', diElements);
35
+ rootDi.set('planeElement', diElements);
36
+ });
34
37
  }
35
38
  }
36
39
 
@@ -0,0 +1,122 @@
1
+ import { domify, classes } from 'min-dom';
2
+ import { find } from 'min-dash';
3
+
4
+ import { escapeHTML } from 'diagram-js/lib/util/EscapeUtil';
5
+ import { getBusinessObject, is } from '../../util/ModelUtil';
6
+ import {
7
+ getPlaneIdFromShape
8
+ } from '../../util/DrilldownUtil';
9
+
10
+ var OPEN_CLASS = 'bjs-breadcrumbs-shown';
11
+
12
+
13
+ /**
14
+ * Adds overlays that allow switching planes on collapsed subprocesses.
15
+ *
16
+ * @param {eventBus} eventBus
17
+ * @param {elementRegistry} elementRegistry
18
+ * @param {overlays} overlays
19
+ * @param {canvas} canvas
20
+ */
21
+ export default function DrilldownBreadcrumbs(eventBus, elementRegistry, overlays, canvas) {
22
+ var breadcrumbs = domify('<ul class="bjs-breadcrumbs"></ul>');
23
+ var container = canvas.getContainer();
24
+ var containerClasses = classes(container);
25
+ container.appendChild(breadcrumbs);
26
+
27
+ var boParents = [];
28
+
29
+ // update breadcrumbs if name or ID of the primary shape changes
30
+ eventBus.on('element.changed', function(e) {
31
+ var shape = e.element,
32
+ bo = getBusinessObject(shape);
33
+
34
+ var isPresent = find(boParents, function(el) {
35
+ return el === bo;
36
+ });
37
+
38
+ if (!isPresent) {
39
+ return;
40
+ }
41
+
42
+ updateBreadcrumbs();
43
+ });
44
+
45
+ /**
46
+ * Updates the displayed breadcrumbs. If no element is provided, only the
47
+ * labels are updated.
48
+ *
49
+ * @param {djs.model.Base} [element]
50
+ */
51
+ function updateBreadcrumbs(element) {
52
+ if (element) {
53
+ boParents = getBoParentChain(element);
54
+ }
55
+
56
+ var path = boParents.map(function(parent) {
57
+ var title = escapeHTML(parent.name || parent.id);
58
+ var link = domify('<li><span class="bjs-crumb"><a title="' + title + '">' + title + '</a></span></li>');
59
+
60
+ var parentPlane = canvas.findRoot(getPlaneIdFromShape(parent)) || canvas.findRoot(parent.id);
61
+
62
+ // when the root is a collaboration, the process does not have a corresponding
63
+ // element in the elementRegisty. Instead, we search for the corresponding participant
64
+ if (!parentPlane && is(parent, 'bpmn:Process')) {
65
+ var participant = elementRegistry.find(function(element) {
66
+ var bo = getBusinessObject(element);
67
+ return bo && bo.processRef && bo.processRef === parent;
68
+ });
69
+
70
+ parentPlane = canvas.findRoot(participant.id);
71
+ }
72
+
73
+ link.addEventListener('click', function() {
74
+ canvas.setRootElement(parentPlane);
75
+ });
76
+
77
+ return link;
78
+ });
79
+
80
+ breadcrumbs.innerHTML = '';
81
+
82
+ // show breadcrumbs and expose state to .djs-container
83
+ var visible = path.length > 1;
84
+ containerClasses.toggle(OPEN_CLASS, visible);
85
+
86
+ path.forEach(function(el) {
87
+ breadcrumbs.appendChild(el);
88
+ });
89
+ }
90
+
91
+ eventBus.on('root.set', function(event) {
92
+ updateBreadcrumbs(event.element);
93
+ });
94
+
95
+ }
96
+
97
+ DrilldownBreadcrumbs.$inject = [ 'eventBus', 'elementRegistry', 'overlays', 'canvas' ];
98
+
99
+
100
+ // helpers //////////
101
+
102
+ /**
103
+ * Returns the parents for the element using the business object chain,
104
+ * starting with the root element.
105
+ *
106
+ * @param {djs.model.Shape} child
107
+ *
108
+ * @returns {Array<djs.model.Shape>} parents
109
+ */
110
+ function getBoParentChain(child) {
111
+ var bo = getBusinessObject(child);
112
+
113
+ var parents = [];
114
+
115
+ for (var element = bo; element; element = element.$parent) {
116
+ if (is(element, 'bpmn:SubProcess') || is(element, 'bpmn:Process')) {
117
+ parents.push(element);
118
+ }
119
+ }
120
+
121
+ return parents.reverse();
122
+ }
@@ -0,0 +1,118 @@
1
+ import { is } from '../../util/ModelUtil';
2
+
3
+ /**
4
+ * Move collapsed subprocesses into view when drilling down.
5
+ *
6
+ * Zoom and scroll are saved in a session.
7
+ *
8
+ * @param {eventBus} eventBus
9
+ * @param {canvas} canvas
10
+ */
11
+ export default function DrilldownCentering(eventBus, canvas) {
12
+
13
+ var currentRoot = null;
14
+ var positionMap = new Map();
15
+
16
+ eventBus.on('root.set', function(event) {
17
+ var newRoot = event.element;
18
+ var currentViewbox = canvas.viewbox();
19
+ var storedViewbox = positionMap.get(newRoot);
20
+
21
+ positionMap.set(currentRoot, {
22
+ x: currentViewbox.x,
23
+ y: currentViewbox.y,
24
+ zoom: currentViewbox.scale
25
+ });
26
+
27
+ currentRoot = newRoot;
28
+
29
+ // current root was replaced with a collaboration, we don't update the viewbox
30
+ if (is(newRoot, 'bpmn:Collaboration') && !storedViewbox) {
31
+ return;
32
+ }
33
+
34
+ storedViewbox = storedViewbox || { x: 0, y: 0, zoom: 1 };
35
+
36
+ var dx = (currentViewbox.x - storedViewbox.x) * currentViewbox.scale,
37
+ dy = (currentViewbox.y - storedViewbox.y) * currentViewbox.scale;
38
+
39
+ if (dx !== 0 || dy !== 0) {
40
+ canvas.scroll({
41
+ dx: dx,
42
+ dy: dy
43
+ });
44
+ }
45
+
46
+ if (storedViewbox.zoom !== currentViewbox.scale) {
47
+ canvas.zoom(storedViewbox.zoom, { x: 0, y: 0 });
48
+ }
49
+ });
50
+
51
+ eventBus.on('diagram.clear', function() {
52
+ positionMap.clear();
53
+ currentRoot = null;
54
+ });
55
+
56
+ }
57
+
58
+ DrilldownCentering.$inject = [ 'eventBus', 'canvas' ];
59
+
60
+
61
+ /**
62
+ * ES5 Map implementation. Works.
63
+ */
64
+ function Map() {
65
+
66
+ this._entries = [];
67
+
68
+ this.set = function(key, value) {
69
+
70
+ var found = false;
71
+
72
+ for (var k in this._entries) {
73
+ if (this._entries[k][0] === key) {
74
+ this._entries[k][1] = value;
75
+
76
+ found = true;
77
+
78
+ break;
79
+ }
80
+ }
81
+
82
+ if (!found) {
83
+ this._entries.push([ key, value ]);
84
+ }
85
+ };
86
+
87
+ this.get = function(key) {
88
+
89
+ for (var k in this._entries) {
90
+ if (this._entries[k][0] === key) {
91
+ return this._entries[k][1];
92
+ }
93
+ }
94
+
95
+ return null;
96
+ };
97
+
98
+ this.clear = function() {
99
+ this._entries.length = 0;
100
+ };
101
+
102
+ this.remove = function(key) {
103
+
104
+ var idx = -1;
105
+
106
+ for (var k in this._entries) {
107
+ if (this._entries[k][0] === key) {
108
+ idx = k;
109
+
110
+ break;
111
+ }
112
+ }
113
+
114
+ if (idx !== -1) {
115
+ this._entries.splice(idx, 1);
116
+ }
117
+ };
118
+ }
@@ -0,0 +1,181 @@
1
+ import inherits from 'inherits';
2
+
3
+ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
+ import { is } from '../../util/ModelUtil';
5
+ import { classes, domify } from 'min-dom';
6
+ import { getPlaneIdFromShape } from '../../util/DrilldownUtil';
7
+
8
+ var LOW_PRIORITY = 250;
9
+ 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>';
10
+
11
+ var EMPTY_MARKER = 'bjs-drilldown-empty';
12
+
13
+ export default function DrilldownOverlayBehavior(
14
+ canvas, eventBus, elementRegistry, overlays
15
+ ) {
16
+ CommandInterceptor.call(this, eventBus);
17
+
18
+ this._canvas = canvas;
19
+ this._eventBus = eventBus;
20
+ this._elementRegistry = elementRegistry;
21
+ this._overlays = overlays;
22
+
23
+ var self = this;
24
+
25
+ this.executed('shape.toggleCollapse', LOW_PRIORITY, function(context) {
26
+ var shape = context.shape;
27
+
28
+ // Add overlay to the collapsed shape
29
+ if (self.canDrillDown(shape)) {
30
+ self.addOverlay(shape);
31
+ } else {
32
+ self.removeOverlay(shape);
33
+ }
34
+ }, true);
35
+
36
+
37
+ this.reverted('shape.toggleCollapse', LOW_PRIORITY, function(context) {
38
+ var shape = context.shape;
39
+
40
+ // Add overlay to the collapsed shape
41
+ if (self.canDrillDown(shape)) {
42
+ self.addOverlay(shape);
43
+ } else {
44
+ self.removeOverlay(shape);
45
+ }
46
+ }, true);
47
+
48
+
49
+ this.executed(['shape.create', 'shape.move', 'shape.delete'], LOW_PRIORITY,
50
+ function(context) {
51
+ var oldParent = context.oldParent,
52
+ newParent = context.newParent || context.parent,
53
+ shape = context.shape;
54
+
55
+ // Add overlay to the collapsed shape
56
+ if (self.canDrillDown(shape)) {
57
+ self.addOverlay(shape);
58
+ }
59
+
60
+ self.updateDrilldownOverlay(oldParent);
61
+ self.updateDrilldownOverlay(newParent);
62
+ self.updateDrilldownOverlay(shape);
63
+ }, true);
64
+
65
+
66
+ this.reverted(['shape.create', 'shape.move', 'shape.delete'], LOW_PRIORITY,
67
+ function(context) {
68
+ var oldParent = context.oldParent,
69
+ newParent = context.newParent || context.parent,
70
+ shape = context.shape;
71
+
72
+ // Add overlay to the collapsed shape
73
+ if (self.canDrillDown(shape)) {
74
+ self.addOverlay(shape);
75
+ }
76
+
77
+ self.updateDrilldownOverlay(oldParent);
78
+ self.updateDrilldownOverlay(newParent);
79
+ self.updateDrilldownOverlay(shape);
80
+ }, true);
81
+
82
+
83
+ eventBus.on('import.done', function() {
84
+ elementRegistry.filter(function(e) {
85
+ return self.canDrillDown(e);
86
+ }).map(function(el) {
87
+ self.addOverlay(el);
88
+ });
89
+ });
90
+
91
+ }
92
+
93
+ inherits(DrilldownOverlayBehavior, CommandInterceptor);
94
+
95
+ DrilldownOverlayBehavior.prototype.updateDrilldownOverlay = function(shape) {
96
+ var canvas = this._canvas;
97
+
98
+ if (!shape) {
99
+ return;
100
+ }
101
+
102
+ var root = canvas.findRoot(shape);
103
+ if (root) {
104
+ this.updateOverlayVisibility(root);
105
+ }
106
+ };
107
+
108
+
109
+ DrilldownOverlayBehavior.prototype.canDrillDown = function(element) {
110
+ var canvas = this._canvas;
111
+ return is(element, 'bpmn:SubProcess') && canvas.findRoot(getPlaneIdFromShape(element));
112
+ };
113
+
114
+ /**
115
+ * Updates visibility of the drilldown overlay. If the plane has no elements,
116
+ * the drilldown will be only shown when the element is selected.
117
+ *
118
+ * @param {djs.model.Shape|djs.model.Root} element collapsed shape or root element
119
+ */
120
+ DrilldownOverlayBehavior.prototype.updateOverlayVisibility = function(element) {
121
+ var overlays = this._overlays;
122
+
123
+ var bo = element.businessObject;
124
+
125
+ var overlay = overlays.get({ element: bo.id, type: 'drilldown' })[0];
126
+
127
+ if (!overlay) {
128
+ return;
129
+ }
130
+
131
+ var hasContent = bo && bo.flowElements && bo.flowElements.length;
132
+ classes(overlay.html).toggle(EMPTY_MARKER, !hasContent);
133
+ };
134
+
135
+ /**
136
+ * Attaches a drilldown button to the given element. We assume that the plane has
137
+ * the same id as the element.
138
+ *
139
+ * @param {djs.model.Shape} element collapsed shape
140
+ */
141
+ DrilldownOverlayBehavior.prototype.addOverlay = function(element) {
142
+ var canvas = this._canvas;
143
+ var overlays = this._overlays;
144
+
145
+ var existingOverlays = overlays.get({ element: element, type: 'drilldown' });
146
+ if (existingOverlays.length) {
147
+ this.removeOverlay(element);
148
+ }
149
+
150
+ var button = domify('<button class="bjs-drilldown">' + ARROW_DOWN_SVG + '</button>');
151
+
152
+ button.addEventListener('click', function() {
153
+ canvas.setRootElement(canvas.findRoot(getPlaneIdFromShape(element)));
154
+ });
155
+
156
+ overlays.add(element, 'drilldown', {
157
+ position: {
158
+ bottom: -7,
159
+ right: -8
160
+ },
161
+ html: button
162
+ });
163
+
164
+ this.updateOverlayVisibility(element);
165
+ };
166
+
167
+ DrilldownOverlayBehavior.prototype.removeOverlay = function(element) {
168
+ var overlays = this._overlays;
169
+
170
+ overlays.remove({
171
+ element: element,
172
+ type: 'drilldown'
173
+ });
174
+ };
175
+
176
+ DrilldownOverlayBehavior.$inject = [
177
+ 'canvas',
178
+ 'eventBus',
179
+ 'elementRegistry',
180
+ 'overlays'
181
+ ];