Skip to content

Commit

Permalink
feat(space-tool): allow label behavior for laid out connections
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Jan 6, 2021
1 parent 6738e08 commit 65967cf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
4 changes: 1 addition & 3 deletions lib/features/modeling/cmd/SpaceToolHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ SpaceToolHandler.prototype.updateConnectionWaypoints = function(
target = connection.target,
waypoints = copyWaypoints(connection),
axis = getAxisFromDirection(direction),
layoutHints = {
labelBehavior: false
};
layoutHints = {};

if (includes(affectedShapes, source) && includes(affectedShapes, target)) {

Expand Down
48 changes: 46 additions & 2 deletions test/spec/features/space-tool/SpaceToolSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,14 @@ describe('features/space-tool', function() {
id: 'label',
width: 80, height: 40
});

modeling.createLabel(childShape, { x: 150, y: 250 }, label);

label1 = elementFactory.createLabel({
id: 'label1',
width: 80, height: 40
});

modeling.createLabel(connection, { x: 300, y: 200 }, label1);
}));

Expand All @@ -531,6 +531,50 @@ describe('features/space-tool', function() {
expect(label1.y).to.equal(180);
}));


it('should disallow label behavior', inject(function(dragging, eventBus, spaceTool) {

// when
spaceTool.activateMakeSpace(canvasEvent({ x: 0, y: 0 }));

var layoutConnectionSpy = sinon.spy(function(event) {
var context = event.context,
hints = context.hints;

expect(hints.labelBehavior).to.be.false;
});

eventBus.on('commandStack.connection.updateWaypoints.execute', layoutConnectionSpy);

dragging.move(canvasEvent({ x: 500, y: 0 }));
dragging.end();

// then
expect(layoutConnectionSpy).to.have.been.called;
}));


it('should allow label behavior', inject(function(dragging, eventBus, spaceTool) {

// when
spaceTool.activateMakeSpace(canvasEvent({ x: 300, y: 0 }));

var layoutConnectionSpy = sinon.spy(function(event) {
var context = event.context,
hints = context.hints;

expect(hints.labelBehavior).to.not.be.false;
});

eventBus.on('commandStack.connection.layout.execute', layoutConnectionSpy);

dragging.move(canvasEvent({ x: 800, y: 0 }));
dragging.end();

// then
expect(layoutConnectionSpy).to.have.been.called;
}));

});


Expand Down

0 comments on commit 65967cf

Please sign in to comment.