feat(replace): create bpmn:LinkEventDefinition with empty name

Closes https://github.com/bpmn-io/bpmn-js/issues/1296
This commit is contained in:
Nico Rehwaldt 2020-03-26 21:11:54 +01:00
parent 814a23a7df
commit bf436bef1e
4 changed files with 38 additions and 3 deletions

View File

@ -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');

View File

@ -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;
}
}

View File

@ -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: ''
}
}
},
{

View File

@ -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) {