fix(replace): allow morphing SubProcess -> EventSubProcess

Closes #451
This commit is contained in:
Nico Rehwaldt 2016-01-20 11:22:16 +01:00
parent f6d13ef0a1
commit 305b59e1f3
2 changed files with 25 additions and 4 deletions

View File

@ -3,8 +3,9 @@
var getBusinessObject = require('../../../util/ModelUtil').getBusinessObject;
/**
* Returns true, if an element is from a different type than a target definition.
* Takes into account the type and the event definition type.
* Returns true, if an element is from a different type
* than a target definition. Takes into account the type,
* event definition type and triggeredByEvent property.
*
* @param {djs.model.Base} element
*
@ -19,9 +20,10 @@ function isDifferentType(element) {
eventDefinition = businessObject.eventDefinitions && businessObject.eventDefinitions[0].$type;
var isEventDefinitionEqual = target.eventDefinition == eventDefinition,
isTypeEqual = businessObject.$type == target.type;
isTypeEqual = businessObject.$type == target.type,
isTriggeredByEventEqual = businessObject.triggeredByEvent == target.triggeredByEvent;
return (!isEventDefinitionEqual && isTypeEqual) || !isTypeEqual;
return !isTypeEqual || !isEventDefinitionEqual || !isTriggeredByEventEqual;
};
}

View File

@ -545,6 +545,25 @@ describe('features/replace-menu', function() {
}));
it('should replace sub processes -> event sub process',
inject(function(popupMenu, bpmnReplace, elementRegistry) {
// given
var subProcess = elementRegistry.get('SubProcess');
openPopup(subProcess);
var entry = queryEntry(popupMenu, 'replace-with-event-subprocess');
// when
// replacing the expanded sub process with a eventSubProcess
var eventSubProcess = popupMenu.trigger(globalEvent(entry, { x: 0, y: 0 }));
// then
expect(eventSubProcess.businessObject.triggeredByEvent).to.be.true;
}));
it('should retain the loop characteristics and the expanded status for transactions',
inject(function(popupMenu, bpmnReplace, elementRegistry) {