mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-02-14 09:57:20 +00:00
67 lines
1.4 KiB
JavaScript
67 lines
1.4 KiB
JavaScript
|
import inherits from 'inherits';
|
||
|
|
||
|
import ConnectPreview from 'diagram-js/lib/features/connect/ConnectPreview';
|
||
|
|
||
|
/**
|
||
|
* Shows connection preview during connect.
|
||
|
*
|
||
|
* @param {Canvas} canvas
|
||
|
* @param {BpmnRules} bpmnRules
|
||
|
* @param {ElementFactory} elementFactory
|
||
|
* @param {EventBus} eventBus
|
||
|
* @param {GraphicsFactory} graphicsFactory
|
||
|
* @param {didi.Injector} injector
|
||
|
*/
|
||
|
export default function BpmnConnectPreview(
|
||
|
bpmnRules,
|
||
|
canvas,
|
||
|
elementFactory,
|
||
|
eventBus,
|
||
|
graphicsFactory,
|
||
|
injector
|
||
|
) {
|
||
|
ConnectPreview.call(
|
||
|
this,
|
||
|
canvas,
|
||
|
elementFactory,
|
||
|
eventBus,
|
||
|
graphicsFactory,
|
||
|
injector
|
||
|
);
|
||
|
|
||
|
this._bpmnRules = bpmnRules;
|
||
|
}
|
||
|
|
||
|
inherits(BpmnConnectPreview, ConnectPreview);
|
||
|
|
||
|
BpmnConnectPreview.$inject = [
|
||
|
'bpmnRules',
|
||
|
'canvas',
|
||
|
'elementFactory',
|
||
|
'eventBus',
|
||
|
'graphicsFactory',
|
||
|
'injector'
|
||
|
];
|
||
|
|
||
|
/**
|
||
|
* Get connection that connect source and target once connect is finished.
|
||
|
*
|
||
|
* @param {Object|boolean} canConnect
|
||
|
* @param {djs.model.shape} source
|
||
|
* @param {djs.model.shape} target
|
||
|
*
|
||
|
* @returns {djs.model.connection}
|
||
|
*/
|
||
|
BpmnConnectPreview.prototype.getConnection = function(canConnect, source, target) {
|
||
|
var attrs = canConnect;
|
||
|
|
||
|
if (!attrs || !attrs.type) {
|
||
|
attrs = this._bpmnRules.canConnect(source, target);
|
||
|
}
|
||
|
|
||
|
if (!attrs) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
return this._elementFactory.createConnection(attrs);
|
||
|
};
|