diff --git a/public/index.html b/public/index.html
index e8cb34ac2..acfcac3df 100644
--- a/public/index.html
+++ b/public/index.html
@@ -51,7 +51,9 @@
@@ -82,12 +84,6 @@
-
-
-
-
-
-
diff --git a/public/red/history.js b/public/red/history.js
index fa45283b2..71c74ef98 100644
--- a/public/red/history.js
+++ b/public/red/history.js
@@ -129,15 +129,19 @@ RED.history = (function() {
}
}
if (ev.subflow) {
- if (ev.node.in.length > ev.subflow.inputCount) {
- ev.node.in.splice(ev.subflow.inputCount);
- } else if (ev.subflow.inputs.length > 0) {
- ev.node.in = ev.node.in.concat(ev.subflow.inputs);
+ if (ev.subflow.hasOwnProperty('inputCount')) {
+ if (ev.node.in.length > ev.subflow.inputCount) {
+ ev.node.in.splice(ev.subflow.inputCount);
+ } else if (ev.subflow.inputs.length > 0) {
+ ev.node.in = ev.node.in.concat(ev.subflow.inputs);
+ }
}
- if (ev.node.out.length > ev.subflow.outputCount) {
- ev.node.out.splice(ev.subflow.outputCount);
- } else if (ev.subflow.outputs.length > 0) {
- ev.node.out = ev.node.out.concat(ev.subflow.outputs);
+ if (ev.subflow.hasOwnProperty('outputCount')) {
+ if (ev.node.out.length > ev.subflow.outputCount) {
+ ev.node.out.splice(ev.subflow.outputCount);
+ } else if (ev.subflow.outputs.length > 0) {
+ ev.node.out = ev.node.out.concat(ev.subflow.outputs);
+ }
}
RED.nodes.eachNode(function(n) {
if (n.type == "subflow:"+ev.node.id) {
@@ -148,8 +152,6 @@ RED.history = (function() {
}
});
-
-
RED.palette.refresh();
} else {
RED.editor.updateNodeProperties(ev.node);
diff --git a/public/red/ui/editor.js b/public/red/ui/editor.js
index 1bcafeb00..3e30343c2 100644
--- a/public/red/ui/editor.js
+++ b/public/red/ui/editor.js
@@ -750,74 +750,21 @@ RED.editor = (function() {
var wasDirty = RED.view.dirty();
var newName = $("#subflow-input-name").val();
- var newInCount = Number($("#subflow-input-inCount").val())||0;
- var newOutCount = Number($("#subflow-input-outCount").val())||0;
-
- var oldInCount = editing_node.in.length;
- var oldOutCount = editing_node.out.length;
-
+
if (newName != editing_node.name) {
changes['name'] = editing_node.name;
editing_node.name = newName;
changed = true;
$("#btn-workspace-menu-"+editing_node.id.replace(".","-")).text("Subflow: "+newName);
}
-
- var xpos = 40;
- var addedOutputs = [];
- var removedOutputs = [];
- var addedInputs = [];
- var removedInputs = [];
- var removedLinks = [];
-
- if (editing_node.in.length < newInCount) {
- var l = editing_node.in.length;
- for (i=l;i newInCount) {
- removedInputs = editing_node.in.splice(newInCount);
- changed = true;
- }
- if (editing_node.out.length < newOutCount) {
- for (i=editing_node.out.length;i newOutCount) {
- removedOutputs = editing_node.out.splice(newOutCount);
- changed = true;
- }
-
- if (removedOutputs.length > 0 || removedInputs.length > 0) {
- RED.nodes.eachLink(function(l) {
- if (newInCount === 0 && l.source.type == "subflow" && l.source.z == editing_node.id) {
- removedLinks.push(l);
- return;
- }
- if (l.target.type == "subflow" && l.target.z == editing_node.id && l.target.i >= newOutCount) {
- removedLinks.push(l);
- return;
- }
- });
- removedLinks.forEach(function(l) { RED.nodes.removeLink(l)});
- }
+
RED.palette.refresh();
if (changed) {
RED.nodes.eachNode(function(n) {
if (n.type == "subflow:"+editing_node.id) {
n.changed = true;
- n.inputs = editing_node.in.length;
- n.outputs = editing_node.out.length;
- removedLinks = removedLinks.concat(updateNodeProperties(n));
+ updateNodeProperties(n);
}
});
var wasChanged = editing_node.changed;
@@ -827,15 +774,8 @@ RED.editor = (function() {
t:'edit',
node:editing_node,
changes:changes,
- links:removedLinks,
dirty:wasDirty,
- changed:wasChanged,
- subflow: {
- outputCount: oldOutCount,
- inputCount: oldInCount,
- outputs: removedOutputs,
- inputs: removedInputs
- }
+ changed:wasChanged
};
RED.history.push(historyEvent);
@@ -873,8 +813,6 @@ RED.editor = (function() {
editing_node = subflow;
RED.view.state(RED.state.EDITING);
$("#subflow-input-name").val(subflow.name);
- $("#subflow-input-inCount").spinner({ min:0, max:1 }).val(subflow.in.length);
- $("#subflow-input-outCount").spinner({ min:0 }).val(subflow.out.length);
var userCount = 0;
var subflowType = "subflow:"+editing_node.id;
@@ -884,7 +822,6 @@ RED.editor = (function() {
}
});
-
$("#subflow-dialog-user-count").html("There "+(userCount==1?"is":"are")+" "+userCount+" instance"+(userCount==1?" ":"s")+" of this subflow").show();
$("#subflow-dialog").dialog("option","title","Edit flow "+subflow.name).dialog( "open" );
}
diff --git a/public/red/ui/view.js b/public/red/ui/view.js
index c55f0a4ce..acb803333 100644
--- a/public/red/ui/view.js
+++ b/public/red/ui/view.js
@@ -227,10 +227,24 @@ RED.view = (function() {
var drag_line = vis.append("svg:path").attr("class", "drag_line");
- $("#workspace-edit-subflow").click(function(event) {
+ $("#workspace-subflow-edit").click(function(event) {
showSubflowDialog(activeSubflow.id);
event.preventDefault();
});
+ $("#workspace-subflow-add-input").click(function(event) {
+ event.preventDefault();
+ if ($(this).hasClass("disabled")) {
+ return;
+ }
+ addSubflowInput(activeSubflow.id);
+ });
+ $("#workspace-subflow-add-output").click(function(event) {
+ event.preventDefault();
+ if ($(this).hasClass("disabled")) {
+ return;
+ }
+ addSubflowOutput(activeSubflow.id);
+ });
var workspace_tabs = RED.tabs.create({
id: "workspace-tabs",
@@ -252,7 +266,9 @@ RED.view = (function() {
activeWorkspace = tab.id;
activeSubflow = RED.nodes.subflow(activeWorkspace);
-
+ if (activeSubflow) {
+ $("#workspace-subflow-add-input").toggleClass("disabled",activeSubflow.in.length > 0);
+ }
if (workspaceScrollPositions[activeWorkspace]) {
chart.scrollLeft(workspaceScrollPositions[activeWorkspace].left);
chart.scrollTop(workspaceScrollPositions[activeWorkspace].top);
@@ -853,14 +869,15 @@ RED.view = (function() {
var subflowRemovedInputLinks = [];
RED.nodes.eachLink(function(l) {
if (l.source.type == "subflow" && l.source.z == activeSubflow.id && l.source.i == input.i) {
- subflowRemovedLinks.push(l);
+ subflowRemovedInputLinks.push(l);
} else if (l.target.type == "subflow:"+activeSubflow.id) {
- subflowRemovedLinks.push(l);
+ subflowRemovedInputLinks.push(l);
}
});
subflowRemovedInputLinks.forEach(function(l) { RED.nodes.removeLink(l)});
removedLinks = removedLinks.concat(subflowRemovedInputLinks);
activeSubflow.in = [];
+ $("#workspace-subflow-add-input").toggleClass("disabled",false);
}
RED.nodes.eachNode(function(n) {
@@ -1817,7 +1834,104 @@ RED.view = (function() {
function showSubflowDialog(id) {
RED.editor.editSubflow(RED.nodes.subflow(id));
+ }
+ function findAvailableSubflowIOPosition(subflow) {
+ var pos = {x:70,y:70};
+ for (var i=0;i