- Fix undo of multiple nodes.

This commit is contained in:
Paulo Gustavo Veiga 2012-09-24 14:54:19 -03:00
parent acd149bfc9
commit 0dafb4b31b

View File

@ -76,20 +76,30 @@ mindplot.commands.DeleteCommand = new Class({
undoExecute:function (commandContext) { undoExecute:function (commandContext) {
var parent = commandContext.findTopics(this._parentTopicIds); // Add all the topics ...
this._deletedTopicModels.each(function (model) {
commandContext.createTopic(model);
}, this);
// Do they need to be connected ?
this._deletedTopicModels.each(function (model, index) { this._deletedTopicModels.each(function (model, index) {
var topic = commandContext.createTopic(model); var topicModel = this._deletedTopicModels[index];
var topics = commandContext.findTopics(topicModel.getId());
// Was the topic connected? var parentId = this._parentTopicIds[index];
var parentTopic = parent[index]; if (parentId) {
if (parentTopic != null) { var parentTopics = commandContext.findTopics(parentId);
commandContext.connect(topic, parentTopic); commandContext.connect(topics[0], parentTopics[0]);
topic.setOnFocus(true);
} }
}, this); }, this);
// Focus on last recovered topic ..
var firstTopic = this._deletedTopicModels[0];
var topic = commandContext.findTopics(firstTopic.getId())[0];
topic.setOnFocus(true);
// Add rebuild relationships ...
this._deletedRelModel.each(function (model) { this._deletedRelModel.each(function (model) {
commandContext.addRelationship(model); commandContext.addRelationship(model);
}.bind(this)); }.bind(this));