2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
getBpmnJS
|
|
|
|
} from 'test/TestHelper';
|
2015-07-29 13:11:54 +00:00
|
|
|
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
export function connect(source, target, attrs) {
|
2015-07-29 13:11:54 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
var elementRegistry = getBpmnJS().get('elementRegistry'),
|
|
|
|
modeling = getBpmnJS().get('modeling');
|
2015-07-29 13:11:54 +00:00
|
|
|
|
|
|
|
var sourceElement = typeof source === 'string' ? elementRegistry.get(source) : source;
|
|
|
|
var targetElement = typeof target === 'string' ? elementRegistry.get(target) : target;
|
|
|
|
|
|
|
|
// assume
|
|
|
|
expect(sourceElement).to.exist;
|
|
|
|
expect(targetElement).to.exist;
|
|
|
|
|
|
|
|
return modeling.connect(sourceElement, targetElement, attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
export function reconnectEnd(connection, target, docking) {
|
2015-07-29 13:11:54 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
var elementRegistry = getBpmnJS().get('elementRegistry'),
|
|
|
|
modeling = getBpmnJS().get('modeling');
|
2015-07-29 13:11:54 +00:00
|
|
|
|
|
|
|
var connectionElement = typeof connection === 'string' ? elementRegistry.get(connection) : connection;
|
|
|
|
var targetElement = typeof target === 'string' ? elementRegistry.get(target) : target;
|
|
|
|
|
|
|
|
// assume
|
|
|
|
expect(connectionElement).to.exist;
|
|
|
|
expect(targetElement).to.exist;
|
|
|
|
|
|
|
|
return modeling.reconnectEnd(connectionElement, targetElement, docking);
|
|
|
|
}
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
|
|
|
|
export function element(id) {
|
|
|
|
return getBpmnJS().get('elementRegistry').get(id);
|
2015-07-29 13:11:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
export function move(shape, delta) {
|
|
|
|
|
|
|
|
var elementRegistry = getBpmnJS().get('elementRegistry'),
|
|
|
|
modeling = getBpmnJS().get('modeling');
|
2015-07-29 13:11:54 +00:00
|
|
|
|
|
|
|
var shapeElement = typeof shape === 'string' ? elementRegistry.get(shape) : shape;
|
|
|
|
|
|
|
|
// assume
|
|
|
|
expect(shapeElement).to.exist;
|
|
|
|
|
2015-08-13 08:51:52 +00:00
|
|
|
modeling.moveElements([shapeElement], delta);
|
2015-07-29 13:11:54 +00:00
|
|
|
|
|
|
|
return shapeElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
// debugging
|
2018-04-02 19:01:53 +00:00
|
|
|
export function inspect(element) {
|
2015-07-29 13:11:54 +00:00
|
|
|
console.log(JSON.stringify(element));
|
2018-04-02 19:01:53 +00:00
|
|
|
}
|