diff --git a/lib/features/drilldown/SubprocessCompatibility.js b/lib/features/drilldown/SubprocessCompatibility.js index 0064be68..2bd76c13 100644 --- a/lib/features/drilldown/SubprocessCompatibility.js +++ b/lib/features/drilldown/SubprocessCompatibility.js @@ -1,6 +1,6 @@ import { asBounds, asTRBL } from 'diagram-js/lib/layout/LayoutUtil'; -import { is } from '../../util/ModelUtil'; +import { is, isAny } from '../../util/ModelUtil'; var DEFAULT_POSITION = { x: 180, @@ -79,7 +79,7 @@ SubprocessCompatibility.prototype.createNewDiagrams = function(plane) { collapsedElements.push(bo); } - if (is(parent, 'bpmn:SubProcess') && parent !== plane.bpmnElement) { + if (shouldMoveToPlane(bo, plane)) { // don't change the array while we iterate over it elementsToMove.push({ diElement: diElement, parent: parent }); @@ -168,7 +168,7 @@ SubprocessCompatibility.prototype.createDiagram = function(bo) { SubprocessCompatibility.$inject = [ 'eventBus', 'moddle' ]; -// helpers +// helpers ////////////////////////// function findRootDiagram(element) { if (is(element, 'bpmndi:BPMNDiagram')) { @@ -199,3 +199,20 @@ function getPlaneBounds(plane) { return asBounds(planeTrbl); } + +function shouldMoveToPlane(bo, plane) { + var parent = bo.$parent; + + // don't move elements that are already on the plane + if (!is(parent, 'bpmn:SubProcess') || parent === plane.bpmnElement) { + return false; + } + + // dataAssociations are children of the subprocess but rendered on process level + // cf. https://github.com/bpmn-io/bpmn-js/issues/1619 + if (isAny(bo, ['bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation'])) { + return false; + } + + return true; +} diff --git a/lib/import/Importer.js b/lib/import/Importer.js index 801adcd2..af1552c4 100644 --- a/lib/import/Importer.js +++ b/lib/import/Importer.js @@ -124,7 +124,7 @@ export function importBpmnDiagram(diagram, definitions, bpmnDiagram) { } /** - * Returns all diagrams in the same hirarchy as the requested diagram. + * Returns all diagrams in the same hierarchy as the requested diagram. * Includes all parent and sub process diagrams. * * @param {Array} definitions diff --git a/test/spec/features/drilldown/DrilldownSpec.js b/test/spec/features/drilldown/DrilldownSpec.js index 3786ad1b..acab91e5 100644 --- a/test/spec/features/drilldown/DrilldownSpec.js +++ b/test/spec/features/drilldown/DrilldownSpec.js @@ -416,6 +416,18 @@ describe('features - drilldown', function() { })); + it('should import data associations on subprocess', inject(function(elementRegistry) { + + // when + var dataInputAssociation = elementRegistry.get('DataInputAssociation_1'); + var dataOutputAssociation = elementRegistry.get('DataOutputAssociation_1'); + + // then + expect(dataInputAssociation).to.exist; + expect(dataOutputAssociation).to.exist; + })); + + it('should move inlined elements to sensible position', inject(function(elementRegistry) { // when diff --git a/test/spec/features/drilldown/legacy-subprocesses.bpmn b/test/spec/features/drilldown/legacy-subprocesses.bpmn index 02fa3ac0..ecd14b33 100644 --- a/test/spec/features/drilldown/legacy-subprocesses.bpmn +++ b/test/spec/features/drilldown/legacy-subprocesses.bpmn @@ -3,6 +3,14 @@ + + + DataObjectReference_0kmm4fv + Property_0baelcu + + + DataObjectReference_0kmm4fv + Flow_0obnxbt @@ -18,15 +26,28 @@ + + + + + + + + + + + + +