2018-04-02 19:01:53 +00:00
|
|
|
import { is } from '../../util/ModelUtil';
|
2016-06-08 08:49:33 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import inherits from 'inherits';
|
2016-06-08 08:49:33 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import { forEach } from 'min-dash';
|
|
|
|
|
|
|
|
import AutoResizeProvider from 'diagram-js/lib/features/auto-resize/AutoResizeProvider';
|
2016-06-08 08:49:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This module is a provider for automatically resizing parent BPMN elements
|
|
|
|
*/
|
2018-04-02 19:01:53 +00:00
|
|
|
export default function BpmnAutoResizeProvider(eventBus, modeling) {
|
2016-06-08 08:49:33 +00:00
|
|
|
AutoResizeProvider.call(this, eventBus);
|
|
|
|
|
|
|
|
this._modeling = modeling;
|
|
|
|
}
|
|
|
|
|
|
|
|
inherits(BpmnAutoResizeProvider, AutoResizeProvider);
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
BpmnAutoResizeProvider.$inject = [
|
|
|
|
'eventBus',
|
|
|
|
'modeling'
|
|
|
|
];
|
2016-06-08 08:49:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the given target can be expanded
|
|
|
|
*
|
|
|
|
* @param {djs.model.Shape} target
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
BpmnAutoResizeProvider.prototype.canResize = function(elements, target) {
|
|
|
|
|
|
|
|
if (!is(target, 'bpmn:Participant') && !is(target, 'bpmn:Lane') && !(is(target, 'bpmn:SubProcess'))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var canResize = true;
|
|
|
|
|
|
|
|
forEach(elements, function(element) {
|
|
|
|
|
|
|
|
if (is(element, 'bpmn:Lane') || element.labelTarget) {
|
|
|
|
canResize = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return canResize;
|
|
|
|
};
|