Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Top-Down Modeling #453

Merged
merged 5 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(modeling): accepts layout hints on reconnect
  • Loading branch information
philippfromme committed Apr 7, 2020
commit 2c30e1010691ae70e179b6d0e11f1a83e7a41a69
18 changes: 14 additions & 4 deletions lib/features/modeling/cmd/ReconnectConnectionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,28 @@ ReconnectConnectionHandler.prototype.postExecute = function(context) {
dockingOrPoints = context.dockingOrPoints,
hints = context.hints || {};

var layoutConnectionHints = {};

if (hints.connectionStart) {
layoutConnectionHints.connectionStart = hints.connectionStart;
}

if (hints.connectionEnd) {
layoutConnectionHints.connectionEnd = hints.connectionEnd;
}

if (hints.layoutConnection === false) {
return;
}

var layoutConnectionHints = {};

if (newSource && (!newTarget || hints.docking === 'source')) {
layoutConnectionHints.connectionStart = getDocking(isArray(dockingOrPoints) ? dockingOrPoints[ 0 ] : dockingOrPoints);
philippfromme marked this conversation as resolved.
Show resolved Hide resolved
layoutConnectionHints.connectionStart = layoutConnectionHints.connectionStart
|| getDocking(isArray(dockingOrPoints) ? dockingOrPoints[ 0 ] : dockingOrPoints);
}

if (newTarget && (!newSource || hints.docking === 'target')) {
layoutConnectionHints.connectionEnd = getDocking(isArray(dockingOrPoints) ? dockingOrPoints[ dockingOrPoints.length - 1 ] : dockingOrPoints);
layoutConnectionHints.connectionEnd = layoutConnectionHints.connectionEnd
|| getDocking(isArray(dockingOrPoints) ? dockingOrPoints[ dockingOrPoints.length - 1 ] : dockingOrPoints);
}

if (hints.newWaypoints) {
Expand Down
40 changes: 36 additions & 4 deletions test/spec/features/modeling/ReconnectConnectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe('features/modeling - reconnect connection', function() {

// then
expect(layoutSpy).to.have.been.calledOnce;
expect(layoutSpy.getCall(0).args).to.eql([ connection, { connectionStart: docking }]);
expect(layoutSpy.getCall(0).args).to.eql([connection, { connectionStart: docking }]);

}));

Expand Down Expand Up @@ -221,7 +221,7 @@ describe('features/modeling - reconnect connection', function() {

// then
expect(layoutSpy).to.have.been.calledOnce;
expect(layoutSpy.getCall(0).args).to.eql([ connection, { connectionStart: docking }]);
expect(layoutSpy.getCall(0).args).to.eql([connection, { connectionStart: docking }]);

}));

Expand Down Expand Up @@ -290,7 +290,7 @@ describe('features/modeling - reconnect connection', function() {

// then
expect(layoutSpy).to.have.been.calledOnce;
expect(layoutSpy.getCall(0).args).to.eql([ connection, { connectionEnd: docking }]);
expect(layoutSpy.getCall(0).args).to.eql([connection, { connectionEnd: docking }]);

}));

Expand Down Expand Up @@ -355,14 +355,46 @@ describe('features/modeling - reconnect connection', function() {

// then
expect(layoutSpy).to.have.been.calledOnce;
expect(layoutSpy.getCall(0).args).to.eql([ connection, { connectionEnd: docking }]);
expect(layoutSpy.getCall(0).args).to.eql([connection, { connectionEnd: docking }]);

}));

});

});


describe('hints', function() {

it('should accept layout hints', inject(function(modeling) {

// when
modeling.reconnect(connection, childShape, connection.target, connection.waypoints, {
connectionStart: {
x: 0,
y: 0
},
connectionEnd: {
x: 100,
y: 100
}
});

// then
expect(connection.waypoints).to.eql([
{
x: 0,
y: 0
},
{
x: 100,
y: 100
}
]);
}));

});

});


Expand Down