@@ -16,6 +16,7 @@ import {
16
16
17
17
import {
18
18
getBusinessObject ,
19
+ getDi ,
19
20
is
20
21
} from '../../util/ModelUtil' ;
21
22
@@ -307,9 +308,9 @@ BpmnUpdater.prototype.updateParent = function(element, oldParent) {
307
308
var parentShape = element . parent ;
308
309
309
310
var businessObject = element . businessObject ,
310
- di = element . di ,
311
+ di = getDi ( element ) ,
311
312
parentBusinessObject = parentShape && parentShape . businessObject ,
312
- parentDi = parentShape && parentShape . di ;
313
+ parentDi = getDi ( parentShape ) ;
313
314
314
315
if ( is ( element , 'bpmn:FlowNode' ) ) {
315
316
this . updateFlowNodeRefs ( businessObject , parentBusinessObject , oldParent && oldParent . businessObject ) ;
@@ -343,7 +344,7 @@ BpmnUpdater.prototype.updateParent = function(element, oldParent) {
343
344
344
345
BpmnUpdater . prototype . updateBounds = function ( shape ) {
345
346
346
- var di = shape . di ;
347
+ var di = getDi ( shape ) ;
347
348
348
349
var target = ( shape instanceof Label ) ? this . _getLabel ( di ) : di ;
349
350
@@ -383,14 +384,17 @@ BpmnUpdater.prototype.updateFlowNodeRefs = function(businessObject, newContainme
383
384
384
385
385
386
// update existing sourceElement and targetElement di information
386
- BpmnUpdater . prototype . updateDiConnection = function ( di , newSource , newTarget ) {
387
+ BpmnUpdater . prototype . updateDiConnection = function ( connection , newSource , newTarget ) {
388
+ var connectionDi = getDi ( connection ) ,
389
+ newSourceDi = getDi ( newSource ) ,
390
+ newTargetDi = getDi ( newTarget ) ;
387
391
388
- if ( di . sourceElement && di . sourceElement . bpmnElement !== newSource ) {
389
- di . sourceElement = newSource && newSource . di ;
392
+ if ( connectionDi . sourceElement && connectionDi . sourceElement . bpmnElement !== getBusinessObject ( newSource ) ) {
393
+ connectionDi . sourceElement = newSource && newSourceDi ;
390
394
}
391
395
392
- if ( di . targetElement && di . targetElement . bpmnElement !== newTarget ) {
393
- di . targetElement = newTarget && newTarget . di ;
396
+ if ( connectionDi . targetElement && connectionDi . targetElement . bpmnElement !== getBusinessObject ( newTarget ) ) {
397
+ connectionDi . targetElement = newTarget && newTargetDi ;
394
398
}
395
399
396
400
} ;
@@ -406,6 +410,11 @@ BpmnUpdater.prototype.updateDiParent = function(di, parentDi) {
406
410
return ;
407
411
}
408
412
413
+ // Cover the case where di.$parent === undefined and parentDi === null
414
+ if ( ! parentDi && ! di . $parent ) {
415
+ return ;
416
+ }
417
+
409
418
var planeElements = ( parentDi || di . $parent ) . get ( 'planeElement' ) ;
410
419
411
420
if ( parentDi ) {
@@ -615,71 +624,72 @@ BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent,
615
624
616
625
617
626
BpmnUpdater . prototype . updateConnectionWaypoints = function ( connection ) {
618
- connection . di . set ( 'waypoint' , this . _bpmnFactory . createDiWaypoints ( connection . waypoints ) ) ;
627
+ var di = getDi ( connection ) ;
628
+
629
+ di . set ( 'waypoint' , this . _bpmnFactory . createDiWaypoints ( connection . waypoints ) ) ;
619
630
} ;
620
631
621
632
622
633
BpmnUpdater . prototype . updateConnection = function ( context ) {
623
-
624
634
var connection = context . connection ,
625
635
businessObject = getBusinessObject ( connection ) ,
626
- newSource = getBusinessObject ( connection . source ) ,
627
- newTarget = getBusinessObject ( connection . target ) ,
636
+ newSource = connection . source ,
637
+ newSourceBo = getBusinessObject ( newSource ) ,
638
+ newTarget = connection . target ,
639
+ newTargetBo = getBusinessObject ( connection . target ) ,
628
640
visualParent ;
629
641
630
642
if ( ! is ( businessObject , 'bpmn:DataAssociation' ) ) {
631
643
632
644
var inverseSet = is ( businessObject , 'bpmn:SequenceFlow' ) ;
633
645
634
- if ( businessObject . sourceRef !== newSource ) {
646
+ if ( businessObject . sourceRef !== newSourceBo ) {
635
647
if ( inverseSet ) {
636
648
collectionRemove ( businessObject . sourceRef && businessObject . sourceRef . get ( 'outgoing' ) , businessObject ) ;
637
649
638
- if ( newSource && newSource . get ( 'outgoing' ) ) {
639
- newSource . get ( 'outgoing' ) . push ( businessObject ) ;
650
+ if ( newSourceBo && newSourceBo . get ( 'outgoing' ) ) {
651
+ newSourceBo . get ( 'outgoing' ) . push ( businessObject ) ;
640
652
}
641
653
}
642
654
643
- businessObject . sourceRef = newSource ;
655
+ businessObject . sourceRef = newSourceBo ;
644
656
}
645
657
646
- if ( businessObject . targetRef !== newTarget ) {
658
+ if ( businessObject . targetRef !== newTargetBo ) {
647
659
if ( inverseSet ) {
648
660
collectionRemove ( businessObject . targetRef && businessObject . targetRef . get ( 'incoming' ) , businessObject ) ;
649
661
650
- if ( newTarget && newTarget . get ( 'incoming' ) ) {
651
- newTarget . get ( 'incoming' ) . push ( businessObject ) ;
662
+ if ( newTargetBo && newTargetBo . get ( 'incoming' ) ) {
663
+ newTargetBo . get ( 'incoming' ) . push ( businessObject ) ;
652
664
}
653
665
}
654
666
655
- businessObject . targetRef = newTarget ;
667
+ businessObject . targetRef = newTargetBo ;
656
668
}
657
669
} else
658
670
659
671
if ( is ( businessObject , 'bpmn:DataInputAssociation' ) ) {
660
672
661
673
// handle obnoxious isMsome sourceRef
662
- businessObject . get ( 'sourceRef' ) [ 0 ] = newSource ;
674
+ businessObject . get ( 'sourceRef' ) [ 0 ] = newSourceBo ;
663
675
664
- visualParent = context . parent || context . newParent || newTarget ;
676
+ visualParent = context . parent || context . newParent || newTargetBo ;
665
677
666
- this . updateSemanticParent ( businessObject , newTarget , visualParent ) ;
678
+ this . updateSemanticParent ( businessObject , newTargetBo , visualParent ) ;
667
679
} else
668
680
669
681
if ( is ( businessObject , 'bpmn:DataOutputAssociation' ) ) {
670
- visualParent = context . parent || context . newParent || newSource ;
682
+ visualParent = context . parent || context . newParent || newSourceBo ;
671
683
672
- this . updateSemanticParent ( businessObject , newSource , visualParent ) ;
684
+ this . updateSemanticParent ( businessObject , newSourceBo , visualParent ) ;
673
685
674
686
// targetRef = new target
675
- businessObject . targetRef = newTarget ;
687
+ businessObject . targetRef = newTargetBo ;
676
688
}
677
689
678
690
this . updateConnectionWaypoints ( connection ) ;
679
691
680
- console . log ( context ) ;
681
-
682
- this . updateDiConnection ( businessObject . di , newSource , newTarget ) ;
692
+ this . updateDiConnection ( connection , newSource , newTarget ) ;
683
693
} ;
684
694
685
695
0 commit comments