fix(modeling): update AddLaneHandler to new spaceTool API

Related to https://github.com/camunda/camunda-modeler/issues/1715
This commit is contained in:
Nico Rehwaldt 2020-03-09 10:48:05 +01:00 committed by Nico Rehwaldt
parent 53e7198a47
commit d902a970e8
2 changed files with 56 additions and 6 deletions

View File

@ -77,7 +77,13 @@ AddLaneHandler.prototype.preExecute = function(context) {
var adjustments = spaceTool.calculateAdjustments(allAffected, 'y', offset, spacePos); var adjustments = spaceTool.calculateAdjustments(allAffected, 'y', offset, spacePos);
spaceTool.makeSpace(adjustments.movingShapes, adjustments.resizingShapes, { x: 0, y: offset }, direction); spaceTool.makeSpace(
adjustments.movingShapes,
adjustments.resizingShapes,
{ x: 0, y: offset },
direction,
spacePos
);
// (2) create new lane at open space // (2) create new lane at open space
context.newLane = modeling.createShape({ type: 'bpmn:Lane' }, { context.newLane = modeling.createShape({ type: 'bpmn:Lane' }, {

View File

@ -20,6 +20,8 @@ import { query as domQuery } from 'min-dom';
var DEFAULT_LANE_HEIGHT = 120; var DEFAULT_LANE_HEIGHT = 120;
var testModules = [ coreModule, modelingModule ];
function getBounds(element) { function getBounds(element) {
return pick(element, [ 'x', 'y', 'width', 'height' ]); return pick(element, [ 'x', 'y', 'width', 'height' ]);
@ -32,9 +34,10 @@ describe('features/modeling - add Lane', function() {
var diagramXML = require('./lanes.bpmn'); var diagramXML = require('./lanes.bpmn');
var testModules = [ coreModule, modelingModule ]; beforeEach(bootstrapModeler(diagramXML, {
modules: testModules
}));
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
it('should add after Lane', inject(function(elementRegistry, modeling) { it('should add after Lane', inject(function(elementRegistry, modeling) {
@ -191,9 +194,9 @@ describe('features/modeling - add Lane', function() {
var diagramXML = require('./participant-no-lane.bpmn'); var diagramXML = require('./participant-no-lane.bpmn');
var testModules = [ coreModule, modelingModule ]; beforeEach(bootstrapModeler(diagramXML, {
modules: testModules
beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); }));
it('should add after Participant', inject(function(elementRegistry, modeling) { it('should add after Participant', inject(function(elementRegistry, modeling) {
@ -267,6 +270,47 @@ describe('features/modeling - add Lane', function() {
}); });
describe('flow node handling', function() {
var diagramXML = require('./lanes.bpmn');
beforeEach(bootstrapModeler(diagramXML, {
modules: testModules
}));
it('should move flow nodes and sequence flows', inject(function(elementRegistry, modeling) {
// given
var laneShape = elementRegistry.get('Nested_Lane_B'),
task_Boundary = elementRegistry.get('Task_Boundary'),
boundary = elementRegistry.get('Boundary'),
sequenceFlow = elementRegistry.get('SequenceFlow'),
sequenceFlow_From_Boundary = elementRegistry.get('SequenceFlow_From_Boundary');
// when
var newLane = modeling.addLane(laneShape, 'top');
// then
expect(task_Boundary).to.have.position({ x: 264, y: -57 });
expect(boundary).to.have.position({ x: 311, y: 5 });
expect(sequenceFlow_From_Boundary).to.have.waypoints([
{ x: 329, y: 161 - newLane.height },
{ x: 329, y: 188 - newLane.height },
{ x: 482, y: 188 - newLane.height },
{ x: 482, y: 143 - newLane.height }
]);
expect(sequenceFlow).to.have.waypoints([
{ x: 364, y: 103 - newLane.height },
{ x: 432, y: 103 - newLane.height }
]);
}));
});
describe('Internet Explorer', function() { describe('Internet Explorer', function() {
var diagramXML = require('./participant-single-lane.bpmn'); var diagramXML = require('./participant-single-lane.bpmn');