diff --git a/lib/features/drilldown/DrilldownOverlays.js b/lib/features/drilldown/DrilldownOverlays.js
index f5938a1f..cbdfe79a 100644
--- a/lib/features/drilldown/DrilldownOverlays.js
+++ b/lib/features/drilldown/DrilldownOverlays.js
@@ -3,6 +3,8 @@ import { domify } from 'min-dom';
import { escapeHTML } from 'diagram-js/lib/util/EscapeUtil';
import { getBusinessObject, is } from '../../util/ModelUtil';
+import { isExpanded } from '../../util/DiUtil';
+
var ARROW_DOWN_SVG = '';
/**
@@ -57,36 +59,40 @@ export default function DrilldownOverlays(eventBus, elementRegistry, overlays, c
updateBreadcrumbs(plane);
});
- var createOverlay = function(element) {
+ function canDrillDown(element) {
+ return is(element, 'bpmn:SubProcess') && canvas.getPlane(element.id);
+ }
+
+ function addOverlay(element) {
var html = domify('');
html.addEventListener('click', function() {
canvas.setActivePlane(element.id);
});
- overlays.add(element, {
+ overlays.add(element, 'drilldown', {
position: {
bottom: -7,
right: -8
},
html: html
});
- };
-
- var addOverlays = function(elements) {
- elements.forEach(function(element) {
- if (is(element, 'bpmn:SubProcess')
- && element.collapsed
- && canvas.getPlane(element.id)) {
- createOverlay(element);
- }
- });
- };
+ }
eventBus.on('import.done', function() {
- addOverlays(elementRegistry.filter(function(el) {
- return is(el, 'bpmn:SubProcess');
- }));
+ elementRegistry.filter(canDrillDown).map(addOverlay);
+ });
+
+
+ // TODO(nikku): add dedicated overlays spec to test
+ // interaction with element creation and replace
+ eventBus.on('element.changed', function(event) {
+
+ const element = event.element;
+
+ if (canDrillDown(element)) {
+ addOverlay(element);
+ }
});
}