fix(modeling): properly update sourceRef/targetRef for associations
Related to #90
This commit is contained in:
parent
a8d51a849d
commit
fb86037cdd
|
@ -173,26 +173,27 @@ BpmnUpdater.prototype.updateConnection = function(connection) {
|
|||
newSource = connection.source && connection.source.businessObject,
|
||||
newTarget = connection.target && connection.target.businessObject;
|
||||
|
||||
// don't set incoming / outgoing for associations
|
||||
if(businessObject.$instanceOf('bpmn:Association')) {
|
||||
return;
|
||||
}
|
||||
var inverseSet = businessObject.$instanceOf('bpmn:SequenceFlow');
|
||||
|
||||
if (businessObject.sourceRef !== newSource) {
|
||||
if (inverseSet) {
|
||||
Collections.remove(businessObject.sourceRef && businessObject.sourceRef.get('outgoing'), businessObject);
|
||||
|
||||
if (newSource) {
|
||||
newSource.get('outgoing').push(businessObject);
|
||||
}
|
||||
}
|
||||
|
||||
businessObject.sourceRef = newSource;
|
||||
}
|
||||
if (businessObject.targetRef !== newTarget) {
|
||||
if (inverseSet) {
|
||||
Collections.remove(businessObject.targetRef && businessObject.targetRef.get('incoming'), businessObject);
|
||||
|
||||
if (newTarget) {
|
||||
newTarget.get('incoming').push(businessObject);
|
||||
}
|
||||
}
|
||||
|
||||
businessObject.targetRef = newTarget;
|
||||
}
|
||||
|
|
|
@ -348,6 +348,58 @@ describe('features/modeling - append shape', function() {
|
|||
|
||||
describe('bpmn element support', function() {
|
||||
|
||||
describe('TextAnnotation', function() {
|
||||
|
||||
it('should wire connection source + target', inject(function(elementRegistry, modeling) {
|
||||
|
||||
// given
|
||||
var startEventShape = elementRegistry.getById('StartEvent_1');
|
||||
|
||||
// when
|
||||
var targetShape = modeling.appendTextAnnotation(startEventShape, 'bpmn:TextAnnotation'),
|
||||
target = targetShape.businessObject;
|
||||
|
||||
var connectingConnection = _.find(targetShape.incoming, function(c) {
|
||||
return c.target === targetShape;
|
||||
});
|
||||
|
||||
var connecting = connectingConnection.businessObject;
|
||||
|
||||
// then
|
||||
expect(targetShape).toBeDefined();
|
||||
expect(target.$instanceOf('bpmn:TextAnnotation')).toBe(true);
|
||||
|
||||
expect(connecting.$instanceOf('bpmn:Association')).toBe(true);
|
||||
expect(connecting.sourceRef).toBe(startEventShape.businessObject);
|
||||
expect(connecting.targetRef).toBe(target);
|
||||
}));
|
||||
|
||||
|
||||
it('should undo wire connection source + target', inject(function(elementRegistry, modeling, commandStack) {
|
||||
|
||||
// given
|
||||
var startEventShape = elementRegistry.getById('StartEvent_1');
|
||||
|
||||
var targetShape = modeling.appendTextAnnotation(startEventShape, 'bpmn:TextAnnotation'),
|
||||
target = targetShape.businessObject;
|
||||
|
||||
var connectingConnection = _.find(targetShape.incoming, function(c) {
|
||||
return c.target === targetShape;
|
||||
});
|
||||
|
||||
var connecting = connectingConnection.businessObject;
|
||||
|
||||
// when
|
||||
commandStack.undo();
|
||||
|
||||
// then
|
||||
expect(connecting.sourceRef).toBe(null);
|
||||
expect(connecting.targetRef).toBe(null);
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('ExclusiveGateway', function() {
|
||||
|
||||
it('should append', inject(function(elementRegistry, modeling) {
|
||||
|
|
Loading…
Reference in New Issue