Fix several issues.
This commit is contained in:
@@ -69,7 +69,7 @@ mindplot.model.IMindmap = new Class({
|
||||
$assert(!child.getParent(), 'Child model seems to be already connected');
|
||||
|
||||
// Connect node...
|
||||
parent._appendChild(child);
|
||||
parent.appendChild(child);
|
||||
|
||||
// Remove from the branch ...
|
||||
this.removeBranch(child);
|
||||
@@ -80,7 +80,7 @@ mindplot.model.IMindmap = new Class({
|
||||
$assert(child, 'Child can not be null.');
|
||||
$assert(parent, 'Child model seems to be already connected');
|
||||
|
||||
parent._removeChild(child);
|
||||
parent.removeChild(child);
|
||||
|
||||
this.addBranch(child);
|
||||
},
|
||||
@@ -111,40 +111,21 @@ mindplot.model.IMindmap = new Class({
|
||||
|
||||
var branches = this.getBranches();
|
||||
result = result + "version:" + this.getVersion();
|
||||
result = result + " , [";
|
||||
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
var node = branches[i];
|
||||
if (i != 0) {
|
||||
result = result + ', ';
|
||||
result = result + ',\n ';
|
||||
}
|
||||
result = result + this._toString(node);
|
||||
result = result + "(" + i + ") =>" + node.inspect();
|
||||
}
|
||||
result = result + "]";
|
||||
|
||||
result = result + ' } ';
|
||||
return result;
|
||||
},
|
||||
|
||||
_toString : function(node) {
|
||||
var result = node.inspect();
|
||||
var children = node.getChildren();
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
|
||||
if (i == 0) {
|
||||
result = result + '-> {';
|
||||
} else {
|
||||
result = result + ', ';
|
||||
}
|
||||
|
||||
result = result + this._toString(child);
|
||||
|
||||
if (i == children.length - 1) {
|
||||
result = result + '}';
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
copyTo : function(target) {
|
||||
var source = this;
|
||||
var version = source.getVersion();
|
||||
|
||||
@@ -190,6 +190,16 @@ mindplot.model.INodeModel = new Class({
|
||||
return this.getParent() != null;
|
||||
},
|
||||
|
||||
appendChild : function(node) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
|
||||
connectTo : function(parent) {
|
||||
$assert(parent, "parent can not be null");
|
||||
var mindmap = this.getMindmap();
|
||||
mindmap.connect(parent, this);
|
||||
},
|
||||
|
||||
getPropertiesKeys : function() {
|
||||
throw "Unsupported operation";
|
||||
@@ -268,7 +278,10 @@ mindplot.model.INodeModel = new Class({
|
||||
},
|
||||
|
||||
inspect : function() {
|
||||
return '(type:' + this.getType() + ' , id: ' + this.getId() + ')';
|
||||
return '{ type: ' + this.getType() +
|
||||
' , id: ' + this.getId() +
|
||||
' , text: ' + this.getText() +
|
||||
' }';
|
||||
},
|
||||
|
||||
copyTo : function(target) {
|
||||
@@ -276,7 +289,7 @@ mindplot.model.INodeModel = new Class({
|
||||
var keys = source.getPropertiesKeys();
|
||||
keys.forEach(function(key) {
|
||||
var value = source.getProperty(key);
|
||||
target.putProperty(value);
|
||||
target.putProperty(key, value);
|
||||
});
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,12 @@ mindplot.model.NodeModel = new Class({
|
||||
return result;
|
||||
},
|
||||
|
||||
addChildren : function(){
|
||||
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||
this._children.push(child);
|
||||
child._parent = this;
|
||||
},
|
||||
|
||||
createLink : function(url) {
|
||||
$assert(url, 'Link URL must be specified.');
|
||||
return new mindplot.model.LinkModel(url, this);
|
||||
@@ -116,13 +122,13 @@ mindplot.model.NodeModel = new Class({
|
||||
this._icons.pop();
|
||||
},
|
||||
|
||||
_appendChild : function(child) {
|
||||
appendChild : function(child) {
|
||||
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||
this._children.push(child);
|
||||
child._parent = this;
|
||||
},
|
||||
|
||||
_removeChild : function(child) {
|
||||
removeChild : function(child) {
|
||||
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
|
||||
this._children.erase(child);
|
||||
child._parent = null;
|
||||
@@ -217,12 +223,6 @@ mindplot.model.NodeModel = new Class({
|
||||
|
||||
},
|
||||
|
||||
connectTo : function(parent) {
|
||||
var mindmap = this.getMindmap();
|
||||
mindmap.connect(parent, this);
|
||||
this._parent = parent;
|
||||
},
|
||||
|
||||
deleteNode : function() {
|
||||
var mindmap = this._mindmap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user