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) {
|
|
|
|
|
2021-11-25 10:19:40 +00:00
|
|
|
// do not resize plane elements:
|
|
|
|
// root elements, collapsed sub-processes
|
|
|
|
if (is(target.di, 'bpmndi:BPMNPlane')) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-08 08:49:33 +00:00
|
|
|
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;
|
|
|
|
};
|