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

Make tab operations undoable

This commit is contained in:
Nicholas O'Leary 2013-10-27 20:42:42 +00:00
parent c810edc10e
commit 386520e65b
2 changed files with 19 additions and 1 deletions

View File

@ -36,7 +36,15 @@ RED.history = function() {
for (var i in ev.links) {
RED.nodes.removeLink(ev.links[i]);
}
for (var i in ev.workspaces) {
RED.nodes.removeWorkspace(ev.workspaces[i].id);
RED.view.removeWorkspace(ev.workspaces[i]);
}
} else if (ev.t == "delete") {
for (var i in ev.workspaces) {
RED.nodes.addWorkspace(ev.workspaces[i]);
RED.view.addWorkspace(ev.workspaces[i]);
}
for (var i in ev.nodes) {
RED.nodes.add(ev.nodes[i]);
}

View File

@ -98,6 +98,9 @@ RED.view = function() {
RED.nodes.addWorkspace(ws);
workspace_tabs.addTab(ws);
workspace_tabs.activateTab(tabId);
RED.history.push({t:'add',workspaces:[ws],dirty:dirty});
RED.view.dirty(true);
});
$('#btn-workspace-edit').on("click",function() {
showRenameWorkspaceDialog(activeWorkspace);
@ -1047,7 +1050,11 @@ RED.view = function() {
var workspace = $(this).dialog('option','workspace');
workspace_tabs.removeTab(workspace.id);
// TODO: make undoable
RED.nodes.removeWorkspace(workspace.id);
var historyEvent = RED.nodes.removeWorkspace(workspace.id);
historyEvent.t = 'delete';
historyEvent.dirty = dirty;
historyEvent.workspaces = [workspace];
RED.history.push(historyEvent);
RED.view.dirty(true);
$( this ).dialog( "close" );
}
@ -1074,6 +1081,9 @@ RED.view = function() {
workspace_tabs.addTab(ws);
workspace_tabs.resize();
},
removeWorkspace: function(ws) {
workspace_tabs.removeTab(ws.id);
},
getWorkspace: function() {
return activeWorkspace;
},