Add files via upload
This commit is contained in:
parent
392aebe0df
commit
a3243dd1ba
14 changed files with 871 additions and 0 deletions
43
CustomGlobalConnectRules.ts
Normal file
43
CustomGlobalConnectRules.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
|
||||
export default class CustomGlobalConnectRules extends RuleProvider {
|
||||
static $inject = ['eventBus'];
|
||||
|
||||
constructor(eventBus: any) {
|
||||
super(eventBus);
|
||||
}
|
||||
|
||||
init(): void {
|
||||
// Правило для начала соединения
|
||||
this.addRule('connection.start', (context) => {
|
||||
return true;
|
||||
const { source } = context;
|
||||
|
||||
if (source?.businessObject?.type === 'custom:connectable') {
|
||||
return true; // Разрешить соединение
|
||||
}
|
||||
|
||||
return false; // Запретить соединение
|
||||
});
|
||||
|
||||
// Правило для создания соединения
|
||||
this.addRule('connection.create', (context) => {
|
||||
//return true;
|
||||
const { source, target } = context;
|
||||
// console.log(typeof source);
|
||||
// console.log(source.constructor.name)
|
||||
// instanceof Shape);
|
||||
|
||||
//if (source?.type === Shape)
|
||||
|
||||
//if (
|
||||
// source?.businessObject?.type === 'custom:connectable' &&
|
||||
// target?.businessObject?.type === 'custom:connectable'
|
||||
//) {
|
||||
return { type: 'Connection' };
|
||||
// { type: 'Connection' }; // Тип соединения
|
||||
// }
|
||||
|
||||
return false; // Запретить соединение
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue