From 9ab4c4975ccf990e470ff6508d8317b93b176516 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 4 Sep 2012 01:06:50 -0300 Subject: [PATCH] - Fix undo issues over features. --- mindplot/src/main/javascript/Topic.js | 6 +++++- .../javascript/commands/RemoveFeatureFromTopicCommand.js | 4 +--- mindplot/src/main/javascript/model/FeatureModel.js | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index c0c2e7ba..b19f2b15 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -274,7 +274,7 @@ mindplot.Topic = new Class({ return result; }, - addFeature:function (type, attributes) { + addFeature:function (type, attributes, featureId) { var iconGroup = this.getOrBuildIconGroup(); this.closeEditors(); @@ -282,8 +282,12 @@ mindplot.Topic = new Class({ // Update model ... var feature = model.createFeature(type, attributes); + if ($defined(featureId)) { + feature.setId(featureId); + } model.addFeature(feature); + var result = mindplot.TopicFeature.createIcon(this, feature, this.isReadOnly()); iconGroup.addIcon(result, type == mindplot.TopicFeature.Icon.id && !this.isReadOnly()); diff --git a/mindplot/src/main/javascript/commands/RemoveFeatureFromTopicCommand.js b/mindplot/src/main/javascript/commands/RemoveFeatureFromTopicCommand.js index b3f6eae2..4079eb65 100644 --- a/mindplot/src/main/javascript/commands/RemoveFeatureFromTopicCommand.js +++ b/mindplot/src/main/javascript/commands/RemoveFeatureFromTopicCommand.js @@ -40,9 +40,7 @@ mindplot.commands.RemoveFeatureFromTopicCommand = new Class({ var topic = commandContext.findTopics(this._topicId)[0]; var feature = this._oldFeature; - var newFeature = topic.addFeature(feature.getType(), feature.getAttributes()); - this._featureId = newFeature.getModel().getId(); - + topic.addFeature(feature.getType(), feature.getAttributes(), this._featureId); this._oldFeature = null; } }); \ No newline at end of file diff --git a/mindplot/src/main/javascript/model/FeatureModel.js b/mindplot/src/main/javascript/model/FeatureModel.js index c133f980..0161319e 100644 --- a/mindplot/src/main/javascript/model/FeatureModel.js +++ b/mindplot/src/main/javascript/model/FeatureModel.js @@ -55,6 +55,10 @@ mindplot.model.FeatureModel = new Class({ return this._id; }, + setId : function(id) { + this._id = id; + }, + getType:function() { return this._type; }