chore(modeling): consistently create DI with attrs
This fixes the existing DI creation methods in `BpmnFactory` and simplifies the related `ElementFactory` code that relied on it. In the past args got ignored and passing attrs to the created DI was not possible, now it is. BREAKING CHANGE: With this change the following `BpmnFactory` API methods got reworked to take (businessObject, attrs) as an input: * `BpmnFactory#createDiEdge` * `BpmnFactory#createDiShape` * `BpmnFactory#createDiPlane`
This commit is contained in:
parent
c4206a4d31
commit
bb9dc16cac
|
@ -83,11 +83,10 @@ BpmnFactory.prototype.createDiLabel = function() {
|
|||
};
|
||||
|
||||
|
||||
BpmnFactory.prototype.createDiShape = function(semantic, bounds, attrs) {
|
||||
|
||||
BpmnFactory.prototype.createDiShape = function(semantic, attrs) {
|
||||
return this.create('bpmndi:BPMNShape', assign({
|
||||
bpmnElement: semantic,
|
||||
bounds: this.createDiBounds(bounds)
|
||||
bounds: this.createDiBounds()
|
||||
}, attrs));
|
||||
};
|
||||
|
||||
|
@ -110,14 +109,15 @@ BpmnFactory.prototype.createDiWaypoint = function(point) {
|
|||
};
|
||||
|
||||
|
||||
BpmnFactory.prototype.createDiEdge = function(semantic, waypoints, attrs) {
|
||||
BpmnFactory.prototype.createDiEdge = function(semantic, attrs) {
|
||||
return this.create('bpmndi:BPMNEdge', assign({
|
||||
bpmnElement: semantic
|
||||
bpmnElement: semantic,
|
||||
waypoints: this.createDiWaypoints([])
|
||||
}, attrs));
|
||||
};
|
||||
|
||||
BpmnFactory.prototype.createDiPlane = function(semantic) {
|
||||
return this.create('bpmndi:BPMNPlane', {
|
||||
BpmnFactory.prototype.createDiPlane = function(semantic, attrs) {
|
||||
return this.create('bpmndi:BPMNPlane', assign({
|
||||
bpmnElement: semantic
|
||||
});
|
||||
}, attrs));
|
||||
};
|
|
@ -72,7 +72,7 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
|||
attrs = attrs || {};
|
||||
|
||||
var businessObject = attrs.businessObject,
|
||||
di = attrs.di || {};
|
||||
di = attrs.di;
|
||||
|
||||
if (!businessObject) {
|
||||
if (!attrs.type) {
|
||||
|
@ -85,25 +85,18 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
|||
}
|
||||
|
||||
if (!isModdleDi(di)) {
|
||||
var diAttrs = assign(
|
||||
di || {},
|
||||
{ id: businessObject.id + '_di' }
|
||||
);
|
||||
|
||||
if (elementType === 'root') {
|
||||
di = this._bpmnFactory.createDiPlane(businessObject, [], {
|
||||
id: businessObject.id + '_di'
|
||||
});
|
||||
di = this._bpmnFactory.createDiPlane(businessObject, diAttrs);
|
||||
} else
|
||||
if (elementType === 'connection') {
|
||||
di = this._bpmnFactory.createDiEdge(businessObject, [], {
|
||||
id: businessObject.id + '_di'
|
||||
});
|
||||
di = this._bpmnFactory.createDiEdge(businessObject, diAttrs);
|
||||
} else {
|
||||
di = this._bpmnFactory.createDiShape(businessObject, {}, {
|
||||
id: businessObject.id + '_di'
|
||||
});
|
||||
}
|
||||
|
||||
if (attrs.di) {
|
||||
assign(di, attrs.di);
|
||||
|
||||
delete attrs.di;
|
||||
di = this._bpmnFactory.createDiShape(businessObject, diAttrs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,10 +143,11 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
|||
size = this.getDefaultSize(businessObject, di);
|
||||
|
||||
attrs = assign({
|
||||
businessObject: businessObject,
|
||||
di: di,
|
||||
id: businessObject.id
|
||||
}, size, attrs);
|
||||
}, size, attrs, {
|
||||
businessObject: businessObject,
|
||||
di: di
|
||||
});
|
||||
|
||||
return this.baseCreate(elementType, attrs);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue