Keep fixing issues.
This commit is contained in:
@@ -110,17 +110,15 @@ mindplot.model.IMindmap = new Class({
|
||||
result = '{ ';
|
||||
|
||||
var branches = this.getBranches();
|
||||
result = result + "version:" + this.getVersion();
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
var node = branches[i];
|
||||
if (i != 0) {
|
||||
result = result + ', ';
|
||||
}
|
||||
|
||||
result = result + this._toString(node);
|
||||
}
|
||||
|
||||
result = result + ' } ';
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
@@ -147,18 +145,20 @@ mindplot.model.IMindmap = new Class({
|
||||
return result;
|
||||
},
|
||||
|
||||
copyTo : function(mindmap) {
|
||||
var version = this.getVersion();
|
||||
mindmap.setVersion(version);
|
||||
copyTo : function(target) {
|
||||
var source = this;
|
||||
var version = source.getVersion();
|
||||
target.setVersion(version);
|
||||
|
||||
var desc = this.getDescription();
|
||||
mindmap.setDescription(desc);
|
||||
target.setDescription(desc);
|
||||
|
||||
var sbranchs = this.getBranches();
|
||||
// Then the rest of the branches ...
|
||||
var sbranchs = source.getBranches();
|
||||
sbranchs.forEach(function(snode) {
|
||||
var tnode = mindmap.createNode(snode.getType(), snode.getId());
|
||||
var tnode = target.createNode(snode.getType(), snode.getId());
|
||||
snode.copyTo(tnode);
|
||||
mindmap.addBranch(snode);
|
||||
target.addBranch(tnode);
|
||||
});
|
||||
}
|
||||
});
|
@@ -191,11 +191,11 @@ mindplot.model.INodeModel = new Class({
|
||||
},
|
||||
|
||||
|
||||
putProperty: function(key, value) {
|
||||
getPropertiesKeys : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
setProperty: function(key, value) {
|
||||
putProperty: function(key, value) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
@@ -269,6 +269,16 @@ mindplot.model.INodeModel = new Class({
|
||||
|
||||
inspect : function() {
|
||||
return '(type:' + this.getType() + ' , id: ' + this.getId() + ')';
|
||||
},
|
||||
|
||||
copyTo : function(target) {
|
||||
var source = this;
|
||||
var keys = source.getPropertiesKeys();
|
||||
keys.forEach(function(key) {
|
||||
var value = source.getProperty(key);
|
||||
target.putProperty(value);
|
||||
});
|
||||
return target;
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -28,6 +28,10 @@ mindplot.model.Mindmap = new Class({
|
||||
return this._description;
|
||||
},
|
||||
|
||||
setDescription : function(value) {
|
||||
this._description = value;
|
||||
},
|
||||
|
||||
getId : function() {
|
||||
return this._iconType;
|
||||
},
|
||||
@@ -58,7 +62,7 @@ mindplot.model.Mindmap = new Class({
|
||||
this._branches.push(nodeModel);
|
||||
},
|
||||
|
||||
removeBranch : function(nodeModel){
|
||||
removeBranch : function(nodeModel) {
|
||||
$assert(nodeModel && nodeModel.isNodeModel(), 'Remove node must be invoked with model objects');
|
||||
return this._branches.erase(nodeModel);
|
||||
},
|
||||
|
@@ -40,6 +40,12 @@ mindplot.model.NodeModel = new Class({
|
||||
this._properties[key] = value;
|
||||
},
|
||||
|
||||
|
||||
getProperties: function()
|
||||
{
|
||||
return this._properties;
|
||||
},
|
||||
|
||||
getProperty : function(key) {
|
||||
$defined(key, 'key can not be null');
|
||||
var result = this._properties[key];
|
||||
|
Reference in New Issue
Block a user