feat(features/modeling): assign default size for elements
This commit is contained in:
parent
d729818b94
commit
9456ca9098
|
@ -23,7 +23,8 @@ ElementFactory.prototype.createWithBpmn = function(elementType, attrs) {
|
|||
|
||||
attrs = attrs || {};
|
||||
|
||||
var businessObject = attrs.businessObject;
|
||||
var businessObject = attrs.businessObject,
|
||||
size;
|
||||
|
||||
if (!businessObject) {
|
||||
if (!attrs.type) {
|
||||
|
@ -31,13 +32,15 @@ ElementFactory.prototype.createWithBpmn = function(elementType, attrs) {
|
|||
}
|
||||
|
||||
businessObject = this._bpmnFactory.create(attrs.type);
|
||||
|
||||
_.extend(attrs, {
|
||||
businessObject: businessObject,
|
||||
id: businessObject.id
|
||||
});
|
||||
}
|
||||
|
||||
size = this._getDefaultSize(businessObject);
|
||||
|
||||
attrs = _.extend({
|
||||
businessObject: businessObject,
|
||||
id: businessObject.id
|
||||
}, size, attrs);
|
||||
|
||||
return this.create(elementType, attrs);
|
||||
};
|
||||
|
||||
|
@ -55,4 +58,19 @@ ElementFactory.prototype.createShape = function(attrs) {
|
|||
|
||||
ElementFactory.prototype.createConnection = function(attrs) {
|
||||
return this.createWithBpmn('connection', attrs);
|
||||
};
|
||||
|
||||
ElementFactory.prototype._getDefaultSize = function(semantic) {
|
||||
|
||||
if (semantic.$instanceOf('bpmn:Task')) {
|
||||
return { width: 100, height: 80 };
|
||||
}
|
||||
|
||||
if (semantic.$instanceOf('bpmn:Gateway')) {
|
||||
return { width: 36, height: 36 };
|
||||
}
|
||||
|
||||
if (semantic.$instanceOf('bpmn:Event')) {
|
||||
return { width: 36, height: 36 };
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue