fix(bpmn-updater): keep conditions on element replace
Closes camunda/camunda-modeler#318
This commit is contained in:
parent
b43cff1ec2
commit
e157f1c82f
|
@ -199,21 +199,25 @@ function BpmnUpdater(eventBus, bpmnFactory, connectionDocking, translate) {
|
|||
if ((businessObject.sourceRef && businessObject.sourceRef.default) &&
|
||||
!(is(newTarget, 'bpmn:Activity') ||
|
||||
is(newTarget, 'bpmn:EndEvent') ||
|
||||
is(newTarget, 'bpmn:Gateway') ||
|
||||
is(newTarget, 'bpmn:IntermediateThrowEvent')) ) {
|
||||
context.default = businessObject.sourceRef.default;
|
||||
businessObject.sourceRef.default = undefined;
|
||||
}
|
||||
|
||||
// on reconnectStart -> conditional flow
|
||||
if ((businessObject.conditionExpression) && !is(newSource, 'bpmn:Activity')) {
|
||||
if (oldSource && (businessObject.conditionExpression) &&
|
||||
!(is(newSource, 'bpmn:Activity') ||
|
||||
is(newSource, 'bpmn:Gateway')) ) {
|
||||
context.conditionExpression = businessObject.conditionExpression;
|
||||
businessObject.conditionExpression = undefined;
|
||||
}
|
||||
|
||||
// on reconnectEnd -> conditional flow
|
||||
if ((businessObject.conditionExpression) &&
|
||||
if (oldTarget && (businessObject.conditionExpression) &&
|
||||
!(is(newTarget, 'bpmn:Activity') ||
|
||||
is(newTarget, 'bpmn:EndEvent') ||
|
||||
is(newTarget, 'bpmn:Gateway') ||
|
||||
is(newTarget, 'bpmn:IntermediateThrowEvent')) ) {
|
||||
context.conditionExpression = businessObject.conditionExpression;
|
||||
businessObject.conditionExpression = undefined;
|
||||
|
|
|
@ -88,6 +88,47 @@ describe('features/modeling - update properties', function() {
|
|||
}));
|
||||
|
||||
|
||||
it('updating conditional flow on source replace', inject(function(bpmnReplace, elementRegistry) {
|
||||
|
||||
//given
|
||||
var conditionalFlow = elementRegistry.get('SequenceFlow_3'),
|
||||
serviceTask = elementRegistry.get('ServiceTask_1');
|
||||
|
||||
var conditionExpression = conditionalFlow.businessObject.conditionExpression;
|
||||
|
||||
var userTaskData = {
|
||||
type: 'bpmn:UserTask'
|
||||
};
|
||||
|
||||
// when
|
||||
bpmnReplace.replaceElement(serviceTask, userTaskData);
|
||||
|
||||
// then
|
||||
expect(conditionalFlow.businessObject.conditionExpression).to.eql(conditionExpression);
|
||||
}));
|
||||
|
||||
|
||||
it('updating conditional flow on target replace', inject(function(bpmnReplace, elementRegistry) {
|
||||
|
||||
//given
|
||||
var conditionalFlow = elementRegistry.get('SequenceFlow_3'),
|
||||
endEvent = elementRegistry.get('EndEvent_1');
|
||||
|
||||
var conditionExpression = conditionalFlow.businessObject.conditionExpression;
|
||||
|
||||
var messageEndEventData = {
|
||||
type: 'bpmn:EndEvent',
|
||||
eventDefinitionType: 'bpmn:MessageEventDefinition'
|
||||
};
|
||||
|
||||
// when
|
||||
bpmnReplace.replaceElement(endEvent, messageEndEventData);
|
||||
|
||||
// then
|
||||
expect(conditionalFlow.businessObject.conditionExpression).to.eql(conditionExpression);
|
||||
}));
|
||||
|
||||
|
||||
it('setting name', inject(function(elementRegistry, modeling) {
|
||||
|
||||
// given
|
||||
|
|
Loading…
Reference in New Issue