From e5ab234d0116df4f8adbcbd5a6011172e562edbb Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Thu, 27 Sep 2012 23:28:24 -0300 Subject: [PATCH] - Fix feature issue on redo. --- mindplot/src/main/javascript/Topic.js | 2 +- .../src/main/javascript/model/FeatureModel.js | 45 ++++++++++--------- .../src/main/javascript/model/NodeModel.js | 4 +- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index 5fb97820..598b0357 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -1040,7 +1040,7 @@ mindplot.Topic = new Class({ // Create a connection line ... var outgoingLine = new mindplot.ConnectionLine(this, targetTopic); - outgoingLine.setVisibility(this.isVisible()); + outgoingLine.setVisibility(true); // @Todo: This must be false. Check remove of all nodes and redo. this._outgoingLine = outgoingLine; workspace.appendChild(outgoingLine); diff --git a/mindplot/src/main/javascript/model/FeatureModel.js b/mindplot/src/main/javascript/model/FeatureModel.js index 0161319e..7ec610ac 100644 --- a/mindplot/src/main/javascript/model/FeatureModel.js +++ b/mindplot/src/main/javascript/model/FeatureModel.js @@ -17,58 +17,61 @@ */ mindplot.model.FeatureModel = new Class({ - initialize:function(type) { - $assert(type, 'type can not be null'); + Static:{ + _nextUUID:function () { + if (!$defined(mindplot.model.FeatureModel._uuid)) { + mindplot.model.FeatureModel._uuid = 0; + } + + mindplot.model.FeatureModel._uuid = mindplot.model.FeatureModel._uuid + 1; + console.log(mindplot.model.FeatureModel._uuid); + return mindplot.model.FeatureModel._uuid; + } + }, + + initialize:function (type, id) { + $assert(type, 'type can not be null'); + this._id = $defined(id) ? this._id : mindplot.model.FeatureModel._nextUUID(); - this._id = mindplot.model.FeatureModel._nextUUID(); this._type = type; this._attributes = {}; // Create type method ... - this['is' + type.camelCase() + 'Model'] = function() { + this['is' + type.camelCase() + 'Model'] = function () { return true; }; }, - getAttributes : function() { + getAttributes:function () { return Object.clone(this._attributes); }, - setAttributes : function(attributes) { + setAttributes:function (attributes) { for (key in attributes) { this["set" + key.capitalize()](attributes[key]); } }, - setAttribute : function(key, value) { + setAttribute:function (key, value) { $assert(key, 'key id can not be null'); this._attributes[key] = value; }, - getAttribute : function(key) { + getAttribute:function (key) { $assert(key, 'key id can not be null'); return this._attributes[key]; }, - getId : function() { + getId:function () { return this._id; }, - setId : function(id) { + setId:function (id) { this._id = id; }, - getType:function() { + getType:function () { return this._type; } -}); - -mindplot.model.FeatureModel._nextUUID = function() { - if (!$defined(this._uuid)) { - this._uuid = 0; - } - - this._uuid = this._uuid + 1; - return this._uuid; -}; +}); \ No newline at end of file diff --git a/mindplot/src/main/javascript/model/NodeModel.js b/mindplot/src/main/javascript/model/NodeModel.js index 24dc61fd..c19c1a48 100644 --- a/mindplot/src/main/javascript/model/NodeModel.js +++ b/mindplot/src/main/javascript/model/NodeModel.js @@ -47,7 +47,9 @@ mindplot.model.NodeModel = new Class({ removeFeature:function (feature) { $assert(feature, 'feature can not be null'); - this._feature.erase(feature); + this._feature = this._feature.filter(function (f) { + return feature.getId() != f.getId(); + }); }, findFeatureByType:function (type) {