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({
|
return this.create('bpmndi:BPMNShape', assign({
|
||||||
bpmnElement: semantic,
|
bpmnElement: semantic,
|
||||||
bounds: this.createDiBounds(bounds)
|
bounds: this.createDiBounds()
|
||||||
}, attrs));
|
}, 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({
|
return this.create('bpmndi:BPMNEdge', assign({
|
||||||
bpmnElement: semantic
|
bpmnElement: semantic,
|
||||||
|
waypoints: this.createDiWaypoints([])
|
||||||
}, attrs));
|
}, attrs));
|
||||||
};
|
};
|
||||||
|
|
||||||
BpmnFactory.prototype.createDiPlane = function(semantic) {
|
BpmnFactory.prototype.createDiPlane = function(semantic, attrs) {
|
||||||
return this.create('bpmndi:BPMNPlane', {
|
return this.create('bpmndi:BPMNPlane', assign({
|
||||||
bpmnElement: semantic
|
bpmnElement: semantic
|
||||||
});
|
}, attrs));
|
||||||
};
|
};
|
|
@ -72,7 +72,7 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
||||||
attrs = attrs || {};
|
attrs = attrs || {};
|
||||||
|
|
||||||
var businessObject = attrs.businessObject,
|
var businessObject = attrs.businessObject,
|
||||||
di = attrs.di || {};
|
di = attrs.di;
|
||||||
|
|
||||||
if (!businessObject) {
|
if (!businessObject) {
|
||||||
if (!attrs.type) {
|
if (!attrs.type) {
|
||||||
|
@ -85,25 +85,18 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isModdleDi(di)) {
|
if (!isModdleDi(di)) {
|
||||||
|
var diAttrs = assign(
|
||||||
|
di || {},
|
||||||
|
{ id: businessObject.id + '_di' }
|
||||||
|
);
|
||||||
|
|
||||||
if (elementType === 'root') {
|
if (elementType === 'root') {
|
||||||
di = this._bpmnFactory.createDiPlane(businessObject, [], {
|
di = this._bpmnFactory.createDiPlane(businessObject, diAttrs);
|
||||||
id: businessObject.id + '_di'
|
|
||||||
});
|
|
||||||
} else
|
} else
|
||||||
if (elementType === 'connection') {
|
if (elementType === 'connection') {
|
||||||
di = this._bpmnFactory.createDiEdge(businessObject, [], {
|
di = this._bpmnFactory.createDiEdge(businessObject, diAttrs);
|
||||||
id: businessObject.id + '_di'
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
di = this._bpmnFactory.createDiShape(businessObject, {}, {
|
di = this._bpmnFactory.createDiShape(businessObject, diAttrs);
|
||||||
id: businessObject.id + '_di'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attrs.di) {
|
|
||||||
assign(di, attrs.di);
|
|
||||||
|
|
||||||
delete attrs.di;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,10 +143,11 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
||||||
size = this.getDefaultSize(businessObject, di);
|
size = this.getDefaultSize(businessObject, di);
|
||||||
|
|
||||||
attrs = assign({
|
attrs = assign({
|
||||||
businessObject: businessObject,
|
|
||||||
di: di,
|
|
||||||
id: businessObject.id
|
id: businessObject.id
|
||||||
}, size, attrs);
|
}, size, attrs, {
|
||||||
|
businessObject: businessObject,
|
||||||
|
di: di
|
||||||
|
});
|
||||||
|
|
||||||
return this.baseCreate(elementType, attrs);
|
return this.baseCreate(elementType, attrs);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue