Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ChoreoRules.prototype.canConnect = function(source, target, connection) {
if (!is(connection, 'bpmn:DataAssociation')) {
if (is(source, 'bpmn:EventBasedGateway') && is(target, 'bpmn:ChoreographyTask')) {
// event-based gateways can connect to choreography tasks
return { type: 'bpmn:SequenceFlow' };
}
}
return BpmnRules.prototype.canConnect.call(this, source, target, connection);
};
ChoreoRules.prototype.canResize = function(shape, newBounds) {
if (is(shape, 'bpmn:ChoreographyActivity')) {
// choreography activities can be resized
return true;
} else if (shape.type === 'bpmn:Participant') {
// participants (= participant bands) can not be resized
return false;
}
return BpmnRules.prototype.canResize.call(this, shape, newBounds);
};
ChoreoRules.prototype.canCreate = function(shape, target, source, position) {
if (is(target, 'bpmn:Choreography')) {
// elements can be created within a choreography
return true;
} else if (is(target, 'bpmn:SubChoreography') && target.collapsed) {
// elements can not be placed on collapsed sub-choreographies
return false;
}
return BpmnRules.prototype.canCreate.call(this, shape, target, source, position);
};
ChoreoRules.prototype.canMove = function(shapes, target) {
// participant bands and messages are not movable
let isNotMovable = function(shape) {
return is(shape, 'bpmn:Participant') || is(shape, 'bpmn:Message');
};
if (shapes.some(isNotMovable)) {
return false;
}
return BpmnRules.prototype.canMove.call(this, shapes, target);
};
ChoreoRules.prototype.canConnectSequenceFlow = function(source, target) {
if (is(source, 'bpmn:EventBasedGateway') && is(target, 'bpmn:ChoreographyActivity')) {
return true;
}
return BpmnRules.prototype.canConnectSequenceFlow.call(this, source, target);
};