fix(rules): always allow associations from/to TextAnnotation

This commit is contained in:
Nico Rehwaldt 2016-01-21 14:19:59 +01:00 committed by pedesen
parent 7190f8bef8
commit d8ace12308
2 changed files with 49 additions and 20 deletions

View File

@ -81,6 +81,10 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
businessObject.isInterrupting = false;
}
if (attrs.associationDirection) {
businessObject.associationDirection = attrs.associationDirection;
}
var eventDefinitions,
newEventDefinition;

View File

@ -144,6 +144,15 @@ function getOrganizationalParent(element) {
return bo;
}
function isTextAnnotation(element) {
return is(element, 'bpmn:TextAnnotation');
}
function isCompensationBoundary(element) {
return is(element, 'bpmn:BoundaryEvent') &&
hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
}
function isForCompensation(e) {
return getBusinessObject(e).isForCompensation;
}
@ -224,9 +233,7 @@ function isSequenceFlowSource(element) {
!(is(element, 'bpmn:IntermediateThrowEvent') &&
hasEventDefinition(element, 'bpmn:LinkEventDefinition')
) &&
!(is(element, 'bpmn:BoundaryEvent') &&
hasEventDefinition(element, 'bpmn:CompensateEventDefinition')
) &&
!isCompensationBoundary(element) &&
!isForCompensation(element);
}
@ -281,24 +288,42 @@ function canConnect(source, target, connection) {
return false;
}
if (canConnectMessageFlow(source, target) && !is(connection, 'bpmn:DataAssociation')) {
return { type: 'bpmn:MessageFlow' };
}
if (!is(connection, 'bpmn:DataAssociation')) {
if (canConnectSequenceFlow(source, target) && !is(connection, 'bpmn:DataAssociation')) {
return { type: 'bpmn:SequenceFlow' };
}
var dataAssociation = canConnectDataAssociation(source, target);
if (dataAssociation && (!connection || is(connection, 'bpmn:DataAssociation'))) {
return dataAssociation;
}
if (is(connection, 'bpmn:Association') && !is(connection, 'bpmn:DataAssociation')) {
if (canConnectAssociation(source, target)) {
return { type: 'bpmn:Association' };
if (canConnectMessageFlow(source, target)) {
return { type: 'bpmn:MessageFlow' };
}
if (canConnectSequenceFlow(source, target)) {
return { type: 'bpmn:SequenceFlow' };
}
}
var connectDataAssociation = canConnectDataAssociation(source, target);
if (connectDataAssociation) {
return connectDataAssociation;
}
if (isCompensationBoundary(source) && isForCompensation(target)) {
return {
type: 'bpmn:Association',
associationDirection: 'One'
};
}
if (is(connection, 'bpmn:Association') && canConnectAssociation(source, target)) {
return {
type: 'bpmn:Association'
};
}
if (isTextAnnotation(source) || isTextAnnotation(target)) {
return {
type: 'bpmn:Association'
};
}
return false;
@ -556,7 +581,7 @@ function canResize(shape, newBounds) {
return !newBounds || (newBounds.width >= 250 && newBounds.height >= 50);
}
if (is(shape, 'bpmn:TextAnnotation')) {
if (isTextAnnotation(shape)) {
return true;
}