You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2014/12/11 19:41:04 UTC
[02/25] incubator-nifi git commit: NIFI-28: - Automatically including
any self loops when moving the corresponding component.
NIFI-28:
- Automatically including any self loops when moving the corresponding component.
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/1120b0f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/1120b0f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/1120b0f1
Branch: refs/heads/bootstrap
Commit: 1120b0f1abaa1a1a83079b370bc5618885fe4313
Parents: 0125f3d
Author: Matt Gilman <ma...@gmail.com>
Authored: Tue Dec 9 12:13:26 2014 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Tue Dec 9 12:13:26 2014 -0500
----------------------------------------------------------------------
.../main/webapp/js/nf/canvas/nf-draggable.js | 49 +++++++++++++-------
1 file changed, 33 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/1120b0f1/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-draggable.js
----------------------------------------------------------------------
diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-draggable.js b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-draggable.js
index 33acd0c..0865e7e 100644
--- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-draggable.js
+++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-draggable.js
@@ -25,7 +25,7 @@ nf.Draggable = (function () {
*/
var updateComponentsPosition = function (dragSelection) {
var revision = nf.Client.getRevision();
- var updates = [];
+ var updates = d3.map();
// determine the drag delta
var dragData = dragSelection.datum();
@@ -38,16 +38,15 @@ nf.Draggable = (function () {
if (delta.x === 0 && delta.y === 0) {
return;
}
-
- // go through each selected component
- d3.selectAll('g.component.selected').each(function (d) {
+
+ var updateComponentPosition = function(d) {
var newPosition = {
x: d.component.position.x + delta.x,
y: d.component.position.y + delta.y
};
// update the component positioning
- updates.push($.Deferred(function (deferred) {
+ return $.Deferred(function (deferred) {
$.ajax({
type: 'PUT',
url: d.component.uri,
@@ -82,11 +81,10 @@ nf.Draggable = (function () {
deferred.reject();
});
- }).promise());
- });
-
- // go through each selected connection
- d3.selectAll('g.connection.selected').each(function (d) {
+ }).promise();
+ };
+
+ var updateConnectionPosition = function(d) {
// only update if necessary
if (d.component.bends.length === 0) {
return;
@@ -109,7 +107,7 @@ nf.Draggable = (function () {
};
// update the component positioning
- updates.push($.Deferred(function (deferred) {
+ return $.Deferred(function (deferred) {
$.ajax({
type: 'PUT',
url: d.component.uri,
@@ -146,11 +144,30 @@ nf.Draggable = (function () {
deferred.reject();
});
- }).promise());
+ }).promise();
+ };
+
+ // go through each selected connection
+ d3.selectAll('g.connection.selected').each(function (d) {
+ updates.set(d.component.id, updateConnectionPosition(d));
+ });
+
+ // go through each selected component
+ d3.selectAll('g.component.selected').each(function (d) {
+ // consider any self looping connections
+ var connections = nf.Connection.getComponentConnections(d.component.id);
+ $.each(connections, function(_, connection) {
+ if (!updates.has(connection.id) && nf.CanvasUtils.getConnectionSourceComponentId(connection) === nf.CanvasUtils.getConnectionDestinationComponentId(connection)) {
+ updates.set(connection.id, updateConnectionPosition(nf.Connection.get(connection.id)));
+ }
+ });
+
+ // consider the component itself
+ updates.set(d.component.id, updateComponentPosition(d));
});
// wait for all updates to complete
- $.when.apply(window, updates).done(function () {
+ $.when.apply(window, updates.values()).done(function () {
var dragged = $.makeArray(arguments);
var connections = d3.set();
@@ -251,9 +268,9 @@ nf.Draggable = (function () {
} else {
// update the position of the drag selection
dragSelection.attr('x', function (d) {
- d.x += d3.event.dx;
- return d.x;
- })
+ d.x += d3.event.dx;
+ return d.x;
+ })
.attr('y', function (d) {
d.y += d3.event.dy;
return d.y;