diff --git a/lib/features/modeling/ElementFactory.js b/lib/features/modeling/ElementFactory.js index 8f310cf5..d40fcaed 100644 --- a/lib/features/modeling/ElementFactory.js +++ b/lib/features/modeling/ElementFactory.js @@ -117,7 +117,7 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) { if (attrs.eventDefinitionType) { eventDefinitions = businessObject.get('eventDefinitions') || []; - newEventDefinition = this._bpmnFactory.create(attrs.eventDefinitionType); + newEventDefinition = this._bpmnFactory.create(attrs.eventDefinitionType, attrs.eventDefinitionAttrs); if (attrs.eventDefinitionType === 'bpmn:ConditionalEventDefinition') { newEventDefinition.condition = this._bpmnFactory.create('bpmn:FormalExpression'); diff --git a/lib/features/replace/BpmnReplace.js b/lib/features/replace/BpmnReplace.js index da750921..5547d467 100644 --- a/lib/features/replace/BpmnReplace.js +++ b/lib/features/replace/BpmnReplace.js @@ -173,6 +173,7 @@ export default function BpmnReplace( // i.e. because we copied it if (!hasEventDefinition(newBusinessObject, target.eventDefinitionType)) { newElement.eventDefinitionType = target.eventDefinitionType; + newElement.eventDefinitionAttrs = target.eventDefinitionAttrs; } } diff --git a/lib/features/replace/ReplaceOptions.js b/lib/features/replace/ReplaceOptions.js index 04cb6ab2..07bd2772 100644 --- a/lib/features/replace/ReplaceOptions.js +++ b/lib/features/replace/ReplaceOptions.js @@ -137,7 +137,10 @@ export var INTERMEDIATE_EVENT = [ className: 'bpmn-icon-intermediate-event-catch-link', target: { type: 'bpmn:IntermediateCatchEvent', - eventDefinitionType: 'bpmn:LinkEventDefinition' + eventDefinitionType: 'bpmn:LinkEventDefinition', + eventDefinitionAttrs: { + name: '' + } } }, { @@ -146,7 +149,10 @@ export var INTERMEDIATE_EVENT = [ className: 'bpmn-icon-intermediate-event-throw-link', target: { type: 'bpmn:IntermediateThrowEvent', - eventDefinitionType: 'bpmn:LinkEventDefinition' + eventDefinitionType: 'bpmn:LinkEventDefinition', + eventDefinitionAttrs: { + name: '' + } } }, { diff --git a/test/spec/features/modeling/ElementFactorySpec.js b/test/spec/features/modeling/ElementFactorySpec.js index f69c96fe..5d2a9bbb 100644 --- a/test/spec/features/modeling/ElementFactorySpec.js +++ b/test/spec/features/modeling/ElementFactorySpec.js @@ -73,6 +73,34 @@ describe('features - element factory', function() { })); + it('should create with link event definition', inject(function(elementFactory) { + + // when + var intermediateThrowEvent = elementFactory.createShape({ + type: 'bpmn:IntermediateThrowEvent', + eventDefinitionType: 'bpmn:LinkEventDefinition', + eventDefinitionAttrs: { + name: '' + } + }); + + // then + expect(intermediateThrowEvent).to.exist; + expect(is(intermediateThrowEvent, 'bpmn:IntermediateThrowEvent')).to.be.true; + + var intermediateThrowEventBo = getBusinessObject(intermediateThrowEvent), + eventDefinitions = intermediateThrowEventBo.eventDefinitions; + + expect(eventDefinitions).to.exist; + expect(eventDefinitions).to.have.length(1); + + var eventDefinition = eventDefinitions[ 0 ]; + + expect(is(eventDefinition, 'bpmn:LinkEventDefinition')).to.be.true; + expect(eventDefinition.name).to.eql(''); + })); + + describe('integration', function() { it('should create event definition with ID', inject(function(elementFactory) {