mirror of https://github.com/apache/nifi.git
NIFI-28:
- Automatically including any self loops when moving the corresponding component.
This commit is contained in:
parent
0125f3da3f
commit
1120b0f1ab
|
@ -25,7 +25,7 @@ nf.Draggable = (function () {
|
||||||
*/
|
*/
|
||||||
var updateComponentsPosition = function (dragSelection) {
|
var updateComponentsPosition = function (dragSelection) {
|
||||||
var revision = nf.Client.getRevision();
|
var revision = nf.Client.getRevision();
|
||||||
var updates = [];
|
var updates = d3.map();
|
||||||
|
|
||||||
// determine the drag delta
|
// determine the drag delta
|
||||||
var dragData = dragSelection.datum();
|
var dragData = dragSelection.datum();
|
||||||
|
@ -38,16 +38,15 @@ nf.Draggable = (function () {
|
||||||
if (delta.x === 0 && delta.y === 0) {
|
if (delta.x === 0 && delta.y === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// go through each selected component
|
var updateComponentPosition = function(d) {
|
||||||
d3.selectAll('g.component.selected').each(function (d) {
|
|
||||||
var newPosition = {
|
var newPosition = {
|
||||||
x: d.component.position.x + delta.x,
|
x: d.component.position.x + delta.x,
|
||||||
y: d.component.position.y + delta.y
|
y: d.component.position.y + delta.y
|
||||||
};
|
};
|
||||||
|
|
||||||
// update the component positioning
|
// update the component positioning
|
||||||
updates.push($.Deferred(function (deferred) {
|
return $.Deferred(function (deferred) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
url: d.component.uri,
|
url: d.component.uri,
|
||||||
|
@ -82,11 +81,10 @@ nf.Draggable = (function () {
|
||||||
|
|
||||||
deferred.reject();
|
deferred.reject();
|
||||||
});
|
});
|
||||||
}).promise());
|
}).promise();
|
||||||
});
|
};
|
||||||
|
|
||||||
// go through each selected connection
|
var updateConnectionPosition = function(d) {
|
||||||
d3.selectAll('g.connection.selected').each(function (d) {
|
|
||||||
// only update if necessary
|
// only update if necessary
|
||||||
if (d.component.bends.length === 0) {
|
if (d.component.bends.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -109,7 +107,7 @@ nf.Draggable = (function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
// update the component positioning
|
// update the component positioning
|
||||||
updates.push($.Deferred(function (deferred) {
|
return $.Deferred(function (deferred) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
url: d.component.uri,
|
url: d.component.uri,
|
||||||
|
@ -146,11 +144,30 @@ nf.Draggable = (function () {
|
||||||
|
|
||||||
deferred.reject();
|
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
|
// wait for all updates to complete
|
||||||
$.when.apply(window, updates).done(function () {
|
$.when.apply(window, updates.values()).done(function () {
|
||||||
var dragged = $.makeArray(arguments);
|
var dragged = $.makeArray(arguments);
|
||||||
var connections = d3.set();
|
var connections = d3.set();
|
||||||
|
|
||||||
|
@ -251,9 +268,9 @@ nf.Draggable = (function () {
|
||||||
} else {
|
} else {
|
||||||
// update the position of the drag selection
|
// update the position of the drag selection
|
||||||
dragSelection.attr('x', function (d) {
|
dragSelection.attr('x', function (d) {
|
||||||
d.x += d3.event.dx;
|
d.x += d3.event.dx;
|
||||||
return d.x;
|
return d.x;
|
||||||
})
|
})
|
||||||
.attr('y', function (d) {
|
.attr('y', function (d) {
|
||||||
d.y += d3.event.dy;
|
d.y += d3.event.dy;
|
||||||
return d.y;
|
return d.y;
|
||||||
|
|
Loading…
Reference in New Issue