1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Make subflow delete option more obvious

Fixes #514
This commit is contained in:
Nick O'Leary 2015-01-17 21:02:28 +00:00
parent d8c7ea8144
commit 3f0fcb70a4
3 changed files with 37 additions and 40 deletions

View File

@ -54,9 +54,10 @@
<div id="workspace-add-tab"><a id="btn-workspace-add-tab" href="#"><i class="fa fa-plus"></i></a></div> <div id="workspace-add-tab"><a id="btn-workspace-add-tab" href="#"><i class="fa fa-plus"></i></a></div>
<div id="chart"></div> <div id="chart"></div>
<div id="workspace-toolbar"> <div id="workspace-toolbar">
<a class="button" id="workspace-subflow-edit" href="#"><i class="fa fa-pencil"></i> edit subflow name</a> <a class="button" id="workspace-subflow-edit" href="#"><i class="fa fa-pencil"></i> edit name</a>
<a class="button disabled" id="workspace-subflow-add-input" href="#"><i class="fa fa-plus"></i> input</a> <a class="button disabled" id="workspace-subflow-add-input" href="#"><i class="fa fa-plus"></i> input</a>
<a class="button" id="workspace-subflow-add-output" href="#"><i class="fa fa-plus"></i> output</a> <a class="button" id="workspace-subflow-add-output" href="#"><i class="fa fa-plus"></i> output</a>
<a class="button" id="workspace-subflow-delete" href="#"><i class="fa fa-trash"></i> delete subflow</a>
</div> </div>
</div> </div>

View File

@ -700,45 +700,6 @@ RED.editor = (function() {
closeOnEscape: false, closeOnEscape: false,
width: 500, width: 500,
buttons: [ buttons: [
{
class: 'leftButton',
text: "Delete",
click: function() {
var removedNodes = [];
var removedLinks = [];
var startDirty = RED.view.dirty();
RED.nodes.eachNode(function(n) {
if (n.type == "subflow:"+editing_node.id) {
removedNodes.push(n);
}
if (n.z == editing_node.id) {
removedNodes.push(n);
}
});
for (var i=0;i<removedNodes.length;i++) {
var rmlinks = RED.nodes.remove(removedNodes[i].id);
removedLinks = removedLinks.concat(rmlinks);
}
RED.nodes.removeSubflow(editing_node);
RED.view.removeWorkspace(editing_node);
RED.history.push({
t:'delete',
nodes:removedNodes,
links:removedLinks,
subflow: editing_node,
dirty:startDirty
});
RED.view.dirty(true);
RED.view.redraw();
$( this ).dialog( "close" );
}
},
{ {
id: "subflow-dialog-ok", id: "subflow-dialog-ok",
text: "Ok", text: "Ok",

View File

@ -246,6 +246,41 @@ RED.view = (function() {
addSubflowOutput(activeSubflow.id); addSubflowOutput(activeSubflow.id);
}); });
$("#workspace-subflow-delete").click(function(event) {
event.preventDefault();
var removedNodes = [];
var removedLinks = [];
var startDirty = RED.view.dirty();
RED.nodes.eachNode(function(n) {
if (n.type == "subflow:"+activeSubflow.id) {
removedNodes.push(n);
}
if (n.z == activeSubflow.id) {
removedNodes.push(n);
}
});
for (var i=0;i<removedNodes.length;i++) {
var rmlinks = RED.nodes.remove(removedNodes[i].id);
removedLinks = removedLinks.concat(rmlinks);
}
RED.nodes.removeSubflow(activeSubflow);
RED.history.push({
t:'delete',
nodes:removedNodes,
links:removedLinks,
subflow: activeSubflow,
dirty:startDirty
});
RED.view.removeWorkspace(activeSubflow);
RED.view.dirty(true);
RED.view.redraw();
});
var workspace_tabs = RED.tabs.create({ var workspace_tabs = RED.tabs.create({
id: "workspace-tabs", id: "workspace-tabs",
onchange: function(tab) { onchange: function(tab) {