From 3bd22420808b494463f06a04f3371ea77495fe10 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Thu, 27 Sep 2012 23:41:17 -0300 Subject: [PATCH] - Try to fix feature remove issues. --- mindplot/src/main/javascript/Topic.js | 5 +---- mindplot/src/main/javascript/TopicFeature.js | 8 ++++---- .../commands/RemoveFeatureFromTopicCommand.js | 2 -- mindplot/src/main/javascript/model/FeatureModel.js | 2 +- mindplot/src/main/javascript/model/IconModel.js | 10 +++++----- mindplot/src/main/javascript/model/LinkModel.js | 4 ++-- mindplot/src/main/javascript/model/NoteModel.js | 4 ++-- 7 files changed, 15 insertions(+), 20 deletions(-) diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index 598b0357..a75f5239 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -281,10 +281,7 @@ mindplot.Topic = new Class({ var model = this.getModel(); // Update model ... - var feature = model.createFeature(type, attributes); - if ($defined(featureId)) { - feature.setId(featureId); - } + var feature = model.createFeature(type, attributes,featureId); model.addFeature(feature); diff --git a/mindplot/src/main/javascript/TopicFeature.js b/mindplot/src/main/javascript/TopicFeature.js index b144ecd6..ca21b3cd 100644 --- a/mindplot/src/main/javascript/TopicFeature.js +++ b/mindplot/src/main/javascript/TopicFeature.js @@ -41,14 +41,14 @@ mindplot.TopicFeature = { }); }, - createModel:function (id, attributes) { - $assert(id, 'type can not be null'); + createModel:function (type, attributes, id) { + $assert(type, 'type can not be null'); $assert(attributes, 'attributes can not be null'); var model = mindplot.TopicFeature._featuresMetadataById.filter(function (elem) { - return elem.id == id; + return elem.id == type; })[0].model; - return new model(attributes); + return new model(attributes, id); }, createIcon:function (topic, model, readOnly) { diff --git a/mindplot/src/main/javascript/commands/RemoveFeatureFromTopicCommand.js b/mindplot/src/main/javascript/commands/RemoveFeatureFromTopicCommand.js index 4079eb65..4f8990a0 100644 --- a/mindplot/src/main/javascript/commands/RemoveFeatureFromTopicCommand.js +++ b/mindplot/src/main/javascript/commands/RemoveFeatureFromTopicCommand.js @@ -30,7 +30,6 @@ mindplot.commands.RemoveFeatureFromTopicCommand = new Class({ execute:function (commandContext) { var topic = commandContext.findTopics(this._topicId)[0]; - var feature = topic.findFeatureById(this._featureId); topic.removeFeature(feature); this._oldFeature = feature; @@ -38,7 +37,6 @@ mindplot.commands.RemoveFeatureFromTopicCommand = new Class({ undoExecute:function (commandContext) { var topic = commandContext.findTopics(this._topicId)[0]; - var feature = this._oldFeature; topic.addFeature(feature.getType(), feature.getAttributes(), this._featureId); this._oldFeature = null; diff --git a/mindplot/src/main/javascript/model/FeatureModel.js b/mindplot/src/main/javascript/model/FeatureModel.js index 7ec610ac..955522c5 100644 --- a/mindplot/src/main/javascript/model/FeatureModel.js +++ b/mindplot/src/main/javascript/model/FeatureModel.js @@ -31,7 +31,7 @@ mindplot.model.FeatureModel = new Class({ initialize:function (type, id) { $assert(type, 'type can not be null'); - this._id = $defined(id) ? this._id : mindplot.model.FeatureModel._nextUUID(); + this._id = $defined(id) ? id : mindplot.model.FeatureModel._nextUUID(); this._type = type; this._attributes = {}; diff --git a/mindplot/src/main/javascript/model/IconModel.js b/mindplot/src/main/javascript/model/IconModel.js index 40dcc9f4..06236f8e 100644 --- a/mindplot/src/main/javascript/model/IconModel.js +++ b/mindplot/src/main/javascript/model/IconModel.js @@ -17,17 +17,17 @@ */ mindplot.model.IconModel = new Class({ - Extends: mindplot.model.FeatureModel, - initialize:function(attributes) { - this.parent(mindplot.model.IconModel.FEATURE_TYPE); + Extends:mindplot.model.FeatureModel, + initialize:function (attributes, id) { + this.parent(mindplot.model.IconModel.FEATURE_TYPE, id); this.setIconType(attributes.id); }, - getIconType : function() { + getIconType:function () { return this.getAttribute('id'); }, - setIconType : function(iconType) { + setIconType:function (iconType) { $assert(iconType, 'iconType id can not be null'); this.setAttribute('id', iconType); } diff --git a/mindplot/src/main/javascript/model/LinkModel.js b/mindplot/src/main/javascript/model/LinkModel.js index 259adc87..a2ba595a 100644 --- a/mindplot/src/main/javascript/model/LinkModel.js +++ b/mindplot/src/main/javascript/model/LinkModel.js @@ -18,8 +18,8 @@ mindplot.model.LinkModel = new Class({ Extends:mindplot.model.FeatureModel, - initialize:function (attributes) { - this.parent(mindplot.model.LinkModel.FEATURE_TYPE); + initialize:function (attributes,id) { + this.parent(mindplot.model.LinkModel.FEATURE_TYPE,id); this.setUrl(attributes.url); }, diff --git a/mindplot/src/main/javascript/model/NoteModel.js b/mindplot/src/main/javascript/model/NoteModel.js index 27b320fe..768b4366 100644 --- a/mindplot/src/main/javascript/model/NoteModel.js +++ b/mindplot/src/main/javascript/model/NoteModel.js @@ -18,8 +18,8 @@ mindplot.model.NoteModel = new Class({ Extends:mindplot.model.FeatureModel, - initialize:function (attributes) { - this.parent(mindplot.model.NoteModel.FEATURE_TYPE); + initialize:function (attributes, id) { + this.parent(mindplot.model.NoteModel.FEATURE_TYPE, id); var noteText = attributes.text ? attributes.text : " "; this.setText(noteText); },