mirror of
https://github.com/bpmn-io/bpmn-js.git
synced 2025-08-14 11:11:14 +08:00

committed by
Ricardo Matias

parent
6011de1c4a
commit
c14a87e5ad
@ -14,14 +14,17 @@ var UpdatePropertiesHandler = require('./cmd/UpdatePropertiesHandler'),
|
||||
* @param {EventBus} eventBus
|
||||
* @param {ElementFactory} elementFactory
|
||||
* @param {CommandStack} commandStack
|
||||
* @param {BpmnRules} bpmnRules
|
||||
*/
|
||||
function Modeling(eventBus, elementFactory, commandStack) {
|
||||
function Modeling(eventBus, elementFactory, commandStack, bpmnRules) {
|
||||
BaseModeling.call(this, eventBus, elementFactory, commandStack);
|
||||
|
||||
this._bpmnRules = bpmnRules;
|
||||
}
|
||||
|
||||
inherits(Modeling, BaseModeling);
|
||||
|
||||
Modeling.$inject = [ 'eventBus', 'elementFactory', 'commandStack' ];
|
||||
Modeling.$inject = [ 'eventBus', 'elementFactory', 'commandStack', 'bpmnRules' ];
|
||||
|
||||
module.exports = Modeling;
|
||||
|
||||
@ -44,17 +47,19 @@ Modeling.prototype.updateLabel = function(element, newLabel) {
|
||||
};
|
||||
|
||||
|
||||
var getSharedParent = require('./ModelingUtil').getSharedParent;
|
||||
|
||||
Modeling.prototype.connect = function(source, target, attrs) {
|
||||
|
||||
var sourceBo = source.businessObject,
|
||||
targetBo = target.businessObject;
|
||||
var bpmnRules = this._bpmnRules;
|
||||
|
||||
if (!attrs) {
|
||||
if (sourceBo.$instanceOf('bpmn:FlowNode') &&
|
||||
targetBo.$instanceOf('bpmn:FlowNode') &&
|
||||
!sourceBo.$instanceOf('bpmn:EndEvent') &&
|
||||
!targetBo.$instanceOf('bpmn:StartEvent')) {
|
||||
|
||||
if (bpmnRules.canConnectMessageFlow(source, target)) {
|
||||
attrs = {
|
||||
type: 'bpmn:MessageFlow'
|
||||
};
|
||||
} else
|
||||
if (bpmnRules.canConnectSequenceFlow(source, target)) {
|
||||
attrs = {
|
||||
type: 'bpmn:SequenceFlow'
|
||||
};
|
||||
@ -65,7 +70,7 @@ Modeling.prototype.connect = function(source, target, attrs) {
|
||||
}
|
||||
}
|
||||
|
||||
return this.createConnection(source, target, attrs, source.parent);
|
||||
return this.createConnection(source, target, attrs, getSharedParent(source, target));
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user