Skip to content

Commit

Permalink
WIP #178. Remove port opts that would create a cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
brollb committed Jun 2, 2016
1 parent 3f9370a commit 7495feb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 14 additions & 2 deletions src/visualizers/panels/PipelineEditor/PipelineEditorControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,20 @@ define([

PipelineEditorControl.prototype.getExistingPortMatches = function (portId, isOutput) {
// Get the children nodeIds
var childrenIds = this._client.getNode(this._currentNodeId).getChildrenIds(),
matches = this._getPortMatchFor(portId, childrenIds, isOutput);
var srcOpId = this.getSiblingContaining(portId),
childrenIds,
skipIds, // Either ancestors or predecessors -> no cycles allowed!
skipType = isOutput ? 'Predecessors' : 'Successors',
method = 'get' + skipType,
matches;

childrenIds = this._client.getNode(this._currentNodeId).getChildrenIds();

// Remove either ancestors or descendents
skipIds = this[method](childrenIds.map(id => this._client.getNode(id)), srcOpId);
childrenIds = _.difference(childrenIds, skipIds);

matches = this._getPortMatchFor(portId, childrenIds, isOutput);

// Get the port matches in the children
return matches.map(tuple => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,20 @@ define([
};

PipelineEditorWidget.prototype.disconnectPort = function(portId, connId) {
// Get the src, dst ports (used for better commit messages)
// TODO
this.removeConnection(connId);
};

PipelineEditorWidget.prototype.connectPort = function(nodeId, id, isOutput) {
console.log('port ' + id + ' has been clicked! (', isOutput, ')');
if (this.PORT_STATE === STATE.DEFAULT) {
this.startPortConnection(nodeId, id, isOutput);
} else if (this._selectedPort) {
} else if (this._selectedPort !== id) {
this._logger.info('connecting ' + this._selectedPort + ' to ' + id);
var src = !isOutput ? this._selectedPort : id,
dst = isOutput ? this._selectedPort : id;

this.createConnection(src, dst);
} else {
} else if (!this._selectedPort) {
this._logger.error(`Invalid connection state: ${this.PORT_STATE} w/ ${this._selectedPort}`);
this.resetPortState();
}
Expand Down

0 comments on commit 7495feb

Please sign in to comment.