fix(modeling): create ConditionalEventDefinition with condition
This ensures we always create valid BPMN 2.0 XML when creating conditional start and intermediate events. Closes #747
This commit is contained in:
parent
f15407d95b
commit
1f5c69a58b
|
@ -103,6 +103,10 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
|||
eventDefinitions = businessObject.get('eventDefinitions') || [];
|
||||
newEventDefinition = this._moddle.create(attrs.eventDefinitionType);
|
||||
|
||||
if (attrs.eventDefinitionType === 'bpmn:ConditionalEventDefinition') {
|
||||
newEventDefinition.condition = this._moddle.create('bpmn:FormalExpression');
|
||||
}
|
||||
|
||||
eventDefinitions.push(newEventDefinition);
|
||||
|
||||
newEventDefinition.$parent = businessObject;
|
||||
|
|
|
@ -1226,7 +1226,8 @@ describe('features/replace - bpmn replace', function() {
|
|||
}));
|
||||
|
||||
|
||||
it('should properly set parent of event definitions', inject(function(elementRegistry, modeling, bpmnReplace) {
|
||||
it('should properly set parent of event definitions', inject(
|
||||
function(elementRegistry, modeling, bpmnReplace) {
|
||||
|
||||
var startEvent = elementRegistry.get('StartEvent_1');
|
||||
|
||||
|
@ -1239,7 +1240,27 @@ describe('features/replace - bpmn replace', function() {
|
|||
|
||||
expect(parent).to.exist;
|
||||
expect(parent).to.equal(messageEvent.businessObject);
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should add condition with ConditionalEventDefinition', inject(
|
||||
function(elementRegistry, modeling, bpmnReplace) {
|
||||
|
||||
var startEvent = elementRegistry.get('StartEvent_1');
|
||||
|
||||
// when
|
||||
var messageEvent = bpmnReplace.replaceElement(startEvent, {
|
||||
type: 'bpmn:StartEvent',
|
||||
eventDefinitionType: 'bpmn:ConditionalEventDefinition'
|
||||
});
|
||||
|
||||
var definition = messageEvent.businessObject.eventDefinitions[0];
|
||||
|
||||
// then
|
||||
expect(definition.condition).to.exist;
|
||||
})
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue