chore(modeling): do not expose ElementFactory helpers
Less API surface => BETTER.
This commit is contained in:
parent
948ca245e8
commit
c853e88e54
|
@ -81,7 +81,7 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
|||
delete attrs.colors;
|
||||
}
|
||||
|
||||
this.setAttrs(businessObject, attrs, [
|
||||
applyAttributes(businessObject, attrs, [
|
||||
'processRef',
|
||||
'isInterrupting',
|
||||
'associationDirection',
|
||||
|
@ -89,7 +89,7 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
|||
]);
|
||||
|
||||
if (attrs.isExpanded) {
|
||||
this.setAttr(businessObject.di, attrs, 'isExpanded');
|
||||
applyAttribute(businessObject.di, attrs, 'isExpanded');
|
||||
}
|
||||
|
||||
if (is(businessObject, 'bpmn:ExclusiveGateway')) {
|
||||
|
@ -122,23 +122,6 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
|||
};
|
||||
|
||||
|
||||
ElementFactory.prototype.setAttrs = function(element, attrs, properties) {
|
||||
|
||||
forEach(properties, function(property) {
|
||||
if (attrs[property] !== undefined) {
|
||||
this.setAttr(element, attrs, property);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
|
||||
ElementFactory.prototype.setAttr = function(element, attrs, property) {
|
||||
element[property] = attrs[property];
|
||||
|
||||
delete attrs[property];
|
||||
};
|
||||
|
||||
|
||||
ElementFactory.prototype._getDefaultSize = function(semantic) {
|
||||
|
||||
if (is(semantic, 'bpmn:SubProcess')) {
|
||||
|
@ -200,3 +183,37 @@ ElementFactory.prototype.createParticipantShape = function(collapsed) {
|
|||
|
||||
return this.createShape(attrs);
|
||||
};
|
||||
|
||||
|
||||
//////////// helpers ////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Apply attributes from a map to the given element,
|
||||
* remove attribute from the map on application.
|
||||
*
|
||||
* @param {Base} element
|
||||
* @param {Object} attrs (in/out map of attributes)
|
||||
* @param {Array<String>} attributeNames name of attributes to apply
|
||||
*/
|
||||
function applyAttributes(element, attrs, attributeNames) {
|
||||
|
||||
forEach(attributeNames, function(property) {
|
||||
if (attrs[property] !== undefined) {
|
||||
applyAttribute(element, attrs, property);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply named property to element and drain it from the attrs
|
||||
* collection.
|
||||
*
|
||||
* @param {Base} element
|
||||
* @param {Object} attrs (in/out map of attributes)
|
||||
* @param {String} attributeName to apply
|
||||
*/
|
||||
function applyAttribute(element, attrs, attributeName) {
|
||||
element[attributeName] = attrs[attributeName];
|
||||
|
||||
delete attrs[attributeName];
|
||||
}
|
Loading…
Reference in New Issue