mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-12 01:11:24 +08:00
Add connections for moved workflows
This commit is contained in:
parent
5bb99adb25
commit
667b7671a6
2 changed files with 61 additions and 6 deletions
|
|
@ -1929,13 +1929,38 @@ function initMoveModuleGroups() {
|
||||||
var components = connectedComponents(graph, moduleId.toString());
|
var components = connectedComponents(graph, moduleId.toString());
|
||||||
var group = _.map(components, function(id) { return $("#" + id); });
|
var group = _.map(components, function(id) { return $("#" + id); });
|
||||||
|
|
||||||
// Add this information to form
|
// Add all connections/positions/names to form (since we'll delete nodes)
|
||||||
|
var connectionsDiv = $('#update-canvas form input#connections');
|
||||||
|
var positionsDiv = $('#update-canvas form input#positions');
|
||||||
|
var moduleNamesDiv = $('#update-canvas form input#module-groups');
|
||||||
|
|
||||||
|
// Find all connections with soon-to-be-moved nodes
|
||||||
|
var conns = _.filter(graph.edges(), function(conn) {
|
||||||
|
return _.contains(components, conn[0]) || _.contains(components, conn[1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
connectionsDiv.attr("value", conns.toString());
|
||||||
|
|
||||||
|
var moduleGroupNames = {};
|
||||||
|
var positionsVal = "";
|
||||||
|
var module, id, x, y;
|
||||||
|
_.each(group, function(m) {
|
||||||
|
module = $(m);
|
||||||
|
id = module.attr("id");
|
||||||
|
x = elLeft(module) / GRID_DIST_EDIT_X;
|
||||||
|
y = elTop(module) / GRID_DIST_EDIT_Y;
|
||||||
|
positionsVal += id + "," + x + "," + y + ";";
|
||||||
|
moduleGroupNames[id] = module.attr("data-module-group-name");
|
||||||
|
});
|
||||||
|
positionsDiv.attr("value", positionsVal);
|
||||||
|
moduleNamesDiv.attr("value", JSON.stringify(moduleGroupNames));
|
||||||
|
|
||||||
|
// Add move information to form
|
||||||
var formMoveInput = $("#update-canvas form input#move");
|
var formMoveInput = $("#update-canvas form input#move");
|
||||||
|
|
||||||
moveModules = [];
|
moveModules = [];
|
||||||
_.each(group, function(m) {
|
_.each(group, function(m) {
|
||||||
moveModules.push(m.attr("id"));
|
moveModules.push(m.attr("id"));
|
||||||
deleteModule(m.attr("id"));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Put the array into input
|
// Put the array into input
|
||||||
|
|
@ -1943,6 +1968,10 @@ function initMoveModuleGroups() {
|
||||||
moveVal[moveModules] = moveToExperimentId;
|
moveVal[moveModules] = moveToExperimentId;
|
||||||
formMoveInput.attr("value", JSON.stringify(moveVal));
|
formMoveInput.attr("value", JSON.stringify(moveVal));
|
||||||
|
|
||||||
|
_.each(group, function(m) {
|
||||||
|
deleteModule(m.attr("id"));
|
||||||
|
});
|
||||||
|
|
||||||
// Hide modal
|
// Hide modal
|
||||||
modal.modal("hide");
|
modal.modal("hide");
|
||||||
}
|
}
|
||||||
|
|
@ -2107,7 +2136,15 @@ function deleteModule(id, linkConnections) {
|
||||||
// If the module was moved, we don't need to do anything with it
|
// If the module was moved, we don't need to do anything with it
|
||||||
inputVal = formMoveInput.attr("value");
|
inputVal = formMoveInput.attr("value");
|
||||||
if (!_.isUndefined(inputVal) && inputVal !== "") {
|
if (!_.isUndefined(inputVal) && inputVal !== "") {
|
||||||
if (id in JSON.parse(formMoveInput.val())) {
|
moved = [];
|
||||||
|
$.each(JSON.parse(formMoveInput.val()), function(key, value) {
|
||||||
|
if (key.match(/.*,.*/))
|
||||||
|
moved = moved.concat(key.split(','));
|
||||||
|
else
|
||||||
|
moved.push(key);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (_.contains(moved, id)) {
|
||||||
addToRemoveList = false;
|
addToRemoveList = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -2510,7 +2547,10 @@ function bindEditFormSubmission(gridDistX, gridDistY) {
|
||||||
var moduleNamesDiv = $('#update-canvas form input#module-groups');
|
var moduleNamesDiv = $('#update-canvas form input#module-groups');
|
||||||
|
|
||||||
// Connections are easy, just copy graph data
|
// Connections are easy, just copy graph data
|
||||||
connectionsDiv.attr("value", graph.edges().toString());
|
if (connectionsDiv.val())
|
||||||
|
connectionsDiv.attr("value", connectionsDiv.val() + ',' + graph.edges().toString());
|
||||||
|
else
|
||||||
|
connectionsDiv.attr("value", graph.edges().toString());
|
||||||
|
|
||||||
// Positions are a bit more tricky, but still pretty straightforward
|
// Positions are a bit more tricky, but still pretty straightforward
|
||||||
var moduleGroupNames = {};
|
var moduleGroupNames = {};
|
||||||
|
|
@ -2524,8 +2564,13 @@ function bindEditFormSubmission(gridDistX, gridDistY) {
|
||||||
positionsVal += id + "," + x + "," + y + ";";
|
positionsVal += id + "," + x + "," + y + ";";
|
||||||
moduleGroupNames[id] = module.attr("data-module-group-name");
|
moduleGroupNames[id] = module.attr("data-module-group-name");
|
||||||
});
|
});
|
||||||
positionsDiv.attr("value", positionsVal);
|
positionsDiv.attr("value", positionsDiv.val() + positionsVal);
|
||||||
moduleNamesDiv.attr("value", JSON.stringify(moduleGroupNames));
|
|
||||||
|
if (moduleNamesDiv.val())
|
||||||
|
moduleNamesDiv.attr("value", JSON.stringify($.extend(JSON.parse(moduleNamesDiv.val()),
|
||||||
|
moduleGroupNames)));
|
||||||
|
else
|
||||||
|
moduleNamesDiv.attr("value", JSON.stringify(moduleGroupNames));
|
||||||
|
|
||||||
ignoreUnsavedWorkAlert = true;
|
ignoreUnsavedWorkAlert = true;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,15 @@ class CanvasController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Distinguish between moving modules/module_groups
|
||||||
|
to_move_groups = Hash.new
|
||||||
|
to_move.each do |key, value|
|
||||||
|
if key.match(/.*,.*/)
|
||||||
|
to_move_groups[key.split(',').map(&:to_i)] = value
|
||||||
|
to_move.delete(key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if error then
|
if error then
|
||||||
render_403 and return
|
render_403 and return
|
||||||
end
|
end
|
||||||
|
|
@ -228,6 +237,7 @@ class CanvasController < ApplicationController
|
||||||
to_add,
|
to_add,
|
||||||
to_rename,
|
to_rename,
|
||||||
to_move,
|
to_move,
|
||||||
|
to_move_groups,
|
||||||
to_clone,
|
to_clone,
|
||||||
connections,
|
connections,
|
||||||
positions,
|
positions,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue