feature(rules): add modeling rules for event based gateways
closes #193
This commit is contained in:
parent
18c2b0552e
commit
66801df111
|
@ -251,7 +251,8 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
||||||
|
|
||||||
if (bpmnElement.$instanceOf('bpmn:FlowNode')) {
|
if (bpmnElement.$instanceOf('bpmn:FlowNode')) {
|
||||||
|
|
||||||
if (!bpmnElement.$instanceOf('bpmn:EndEvent')) {
|
if (!bpmnElement.$instanceOf('bpmn:EndEvent') &&
|
||||||
|
!bpmnElement.$instanceOf('bpmn:EventBasedGateway')) {
|
||||||
|
|
||||||
assign(actions, {
|
assign(actions, {
|
||||||
'append.end-event': appendAction('bpmn:EndEvent', 'icon-end-event'),
|
'append.end-event': appendAction('bpmn:EndEvent', 'icon-end-event'),
|
||||||
|
@ -269,6 +270,21 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bpmnElement.$instanceOf('bpmn:EventBasedGateway')) {
|
||||||
|
// TODO Add Receiving Events
|
||||||
|
assign(actions, {
|
||||||
|
'append.receive-task': appendAction('bpmn:ReceiveTask', 'icon-receive'),
|
||||||
|
'connect': {
|
||||||
|
group: 'connect',
|
||||||
|
className: 'icon-connection',
|
||||||
|
action: {
|
||||||
|
click: startConnect,
|
||||||
|
dragstart: startConnect
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
assign(actions, {
|
assign(actions, {
|
||||||
'append.text-annotation': appendAction('bpmn:TextAnnotation', 'icon-text-annotation')
|
'append.text-annotation': appendAction('bpmn:TextAnnotation', 'icon-text-annotation')
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,13 +27,40 @@ ModelingRules.prototype.init = function() {
|
||||||
return a === b;
|
return a === b;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEventConnectionValid(sourceBo, targetBo) {
|
function isEventConnectionInvalid(source, target) {
|
||||||
return targetBo.$instanceOf('bpmn:StartEvent') ||
|
|
||||||
|
var sourceBo = source.businessObject,
|
||||||
|
targetBo = target.businessObject;
|
||||||
|
|
||||||
|
var startEventCheck = targetBo.$instanceOf('bpmn:StartEvent') ||
|
||||||
sourceBo.$instanceOf('bpmn:EndEvent');
|
sourceBo.$instanceOf('bpmn:EndEvent');
|
||||||
|
|
||||||
|
var eventBasedGatewayCheck = false;
|
||||||
|
|
||||||
|
// Ensure target of event based gateway is one of:
|
||||||
|
// receive task, receiving message, timer, signal, condition event
|
||||||
|
if (sourceBo.$instanceOf('bpmn:EventBasedGateway')) {
|
||||||
|
|
||||||
|
eventBasedGatewayCheck = true;
|
||||||
|
|
||||||
|
if (targetBo.$instanceOf('bpmn:ReceiveTask')) {
|
||||||
|
eventBasedGatewayCheck = false;
|
||||||
|
} else if (targetBo.$instanceOf('bpmn:ReceiveMessageEvent')) { // ReceiveMessageEvent check name
|
||||||
|
// TODO waiting for https://github.com/bpmn-io/bpmn-js/issues/192
|
||||||
|
} else if (targetBo.$instanceOf('bpmn:ReceiveTimerEvent')) { // TimerEvent check name
|
||||||
|
// TODO waiting for https://github.com/bpmn-io/bpmn-js/issues/192
|
||||||
|
} else if (targetBo.$instanceOf('bpmn:ReceiveSignalEvent')) { // TimerEvent check name
|
||||||
|
// TODO waiting for https://github.com/bpmn-io/bpmn-js/issues/192
|
||||||
|
} else if (targetBo.$instanceOf('bpmn:ReceiveConditionEvent')) { // TimerEvent check name
|
||||||
|
// TODO waiting for https://github.com/bpmn-io/bpmn-js/issues/192
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rules
|
return startEventCheck || eventBasedGatewayCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// rules
|
||||||
function canConnect(source, target, connection) {
|
function canConnect(source, target, connection) {
|
||||||
|
|
||||||
if (nonExistantOrLabel(source) || nonExistantOrLabel(target)) {
|
if (nonExistantOrLabel(source) || nonExistantOrLabel(target)) {
|
||||||
|
@ -70,7 +97,7 @@ ModelingRules.prototype.init = function() {
|
||||||
|
|
||||||
// Do not allow incoming connections on StartEvents
|
// Do not allow incoming connections on StartEvents
|
||||||
// and outgoing connections on EndEvents
|
// and outgoing connections on EndEvents
|
||||||
if (isEventConnectionValid(sourceBo, targetBo)) {
|
if (isEventConnectionInvalid(source, target)) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue