fix(bpmn-connect-preview): override #getConnection
This commit is contained in:
parent
48fcececbf
commit
1958b2e81b
|
@ -16,6 +16,7 @@ import AutoPlaceModule from './features/auto-place';
|
|||
import AutoResizeModule from './features/auto-resize';
|
||||
import AutoScrollModule from 'diagram-js/lib/features/auto-scroll';
|
||||
import BendpointsModule from 'diagram-js/lib/features/bendpoints';
|
||||
import ConnectModule from './features/connect';
|
||||
import ContextPadModule from './features/context-pad';
|
||||
import CopyPasteModule from './features/copy-paste';
|
||||
import DistributeElementsModule from './features/distribute-elements';
|
||||
|
@ -207,6 +208,7 @@ Modeler.prototype._modelingModules = [
|
|||
AutoScrollModule,
|
||||
AutoResizeModule,
|
||||
BendpointsModule,
|
||||
ConnectModule,
|
||||
ContextPadModule,
|
||||
CopyPasteModule,
|
||||
DistributeElementsModule,
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
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);
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
import BpmnConnectPreview from './BpmnConnectPreview';
|
||||
import ConnectModule from 'diagram-js/lib/features/connect';
|
||||
|
||||
export default {
|
||||
__depends__: [ ConnectModule ],
|
||||
__init__: [ 'connectPreview' ],
|
||||
connectPreview: [ 'type', BpmnConnectPreview ]
|
||||
};
|
Loading…
Reference in New Issue