From a5acdc7bb79c866f544fa2dac5c06016ce08bd60 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 8 Jul 2012 16:43:18 -0300 Subject: [PATCH] - Fix do/redo removal of multiple elements --- mindplot/src/main/javascript/commands/DeleteCommand.js | 7 ++++--- mindplot/src/main/javascript/model/INodeModel.js | 4 ++-- mindplot/src/main/javascript/model/NodeModel.js | 7 +------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/mindplot/src/main/javascript/commands/DeleteCommand.js b/mindplot/src/main/javascript/commands/DeleteCommand.js index a4aca0a3..b9498dc1 100644 --- a/mindplot/src/main/javascript/commands/DeleteCommand.js +++ b/mindplot/src/main/javascript/commands/DeleteCommand.js @@ -49,8 +49,9 @@ mindplot.commands.DeleteCommand = new Class({ commandContext.deleteRelationship(relationship); } - // Delete the node itself ... - this._deletedTopicModels.push(model); + // Store information for undo ... + var clonedModel = model.clone(); + this._deletedTopicModels.push(clonedModel); var outTopic = topic.getOutgoingConnectedTopic(); var outTopicId = null; if (outTopic != null) { @@ -84,7 +85,7 @@ mindplot.commands.DeleteCommand = new Class({ var parentTopic = parent[index]; if (parentTopic != null) { commandContext.connect(topic, parentTopic); - topic.setOnFocus(); + topic.setOnFocus(true); } }.bind(this) diff --git a/mindplot/src/main/javascript/model/INodeModel.js b/mindplot/src/main/javascript/model/INodeModel.js index 7d244452..3dbf5ebe 100644 --- a/mindplot/src/main/javascript/model/INodeModel.js +++ b/mindplot/src/main/javascript/model/INodeModel.js @@ -234,7 +234,7 @@ mindplot.model.INodeModel = new Class({ deleteNode : function() { var mindmap = this.getMindmap(); - console.log("Before:" + mindmap.inspect()); +// console.log("Before:" + mindmap.inspect()); var parent = this.getParent(); if ($defined(parent)) { parent.removeChild(this); @@ -243,7 +243,7 @@ mindplot.model.INodeModel = new Class({ mindmap.removeBranch(this); } // It's an isolated node. It must be a hole branch ... - console.log("After:" + mindmap.inspect()); +// console.log("After:" + mindmap.inspect()); }, getPropertiesKeys : function() { diff --git a/mindplot/src/main/javascript/model/NodeModel.js b/mindplot/src/main/javascript/model/NodeModel.js index d4eeb8e4..04273543 100644 --- a/mindplot/src/main/javascript/model/NodeModel.js +++ b/mindplot/src/main/javascript/model/NodeModel.js @@ -86,7 +86,7 @@ mindplot.model.NodeModel = new Class({ clone : function() { var result = new mindplot.model.NodeModel(this.getType(), this._mindmap); - result._children = this._children.each(function(node) { + result._children = this._children.map(function(node) { var cnode = node.clone(); cnode._parent = result; return cnode; @@ -201,10 +201,5 @@ mindplot.model.NodeModel = new Class({ } } return result; - }, - - - inspect : function() { - return '(type:' + this.getType() + ' , id: ' + this.getId() + ')'; } }); \ No newline at end of file