improve(resize): allow to set minimum size for element

This commit is contained in:
jdotzki 2014-10-14 17:24:42 +02:00
parent 1e224370e2
commit 86f66bc534
3 changed files with 46 additions and 3 deletions

View File

@ -0,0 +1,24 @@
module.exports = {
'bpmn:Task': {
'height': 40,
'width': 40
},
'bpmn:SubProcess': {
'resolver': function(element) {
var isExpanded = element.businessObject.di.isExpanded;
if (isExpanded) {
return {
'height': 100,
'width': 100
};
} else {
return {
'height': 40,
'width': 40
};
}
}
}
};

View File

@ -2,12 +2,13 @@
var _ = require('lodash');
var resizableElements = require('./BpmnResizableElements.json').elements;
var resizableElements = require('./BpmnResizableElements.json').elements,
minimumSize = require('./BpmnMinimumSizes.js');
function BpmnResizeHandler(eventBus, resize) {
var isResizeAllowed = function(element) {
var isResizeAllowed = function isResizeAllowed(element) {
var isAllowed = _.contains(resizableElements, element.type);
if (isAllowed) {
@ -17,9 +18,27 @@ function BpmnResizeHandler(eventBus, resize) {
}
};
var getMinimumSize = function getMinimumSize(element) {
var size = minimumSize[element.type];
if (!size) {
size = {
height: 30,
width: 30
};
}
if (!!size.resolver) {
return size.resolver(element);
} else {
return size;
}
};
// Register Handler
eventBus.on('canvas.init', function() {
resize.registerResizableHandler(isResizeAllowed);
resize.registerMinimumSizeResolver(getMinimumSize);
});
}

View File

@ -32,7 +32,7 @@ describe('palette', function() {
});
}
iit('should should draw palette', function(done) {
it('should should draw palette', function(done) {
var modeler = new Modeler({ container: container });
modeler.createDiagram(function(err) {