Add remove node support.

This commit is contained in:
Paulo Veiga
2011-09-11 00:07:43 -03:00
parent c1e0d52ff5
commit 5a08728686
11 changed files with 69 additions and 149 deletions

View File

@@ -71,7 +71,12 @@ mindplot.collaboration.framework.brix.model.Mindmap = new Class({
addBranch : function(nodeModel) {
$assert(nodeModel, "nodeModel can not be null");
var branches = this._brixModel.get("branches");
branches.add(nodeModel.getBrixModel());
// @Todo: Hack ?
var newModel = mindplot.collaboration.framework.brix.model.NodeModel.create(this._brixFramework, this, nodeModel.getType(), nodeModel.getId());
nodeModel.copyTo(newModel);
branches.add(newModel);
},
removeBranch : function(nodeModel) {

View File

@@ -63,17 +63,19 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
}.bind(this));
children.addListener("valuesRemoved", function(event) {
console.log("remove node:" + funName);
var brixChildren = event.getValues();
for (var i = 0; i < brixChildren.size(); i++) {
var brixNodeModel = brixChildren.get(i);
var cmodel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, brixNodeModel, this.getMindmap());
actionDispatcher.deleteTopics(cmodel.getId());
try {
var brixChildren = event.getValues();
for (var i = 0; i < brixChildren.size(); i++) {
var brixNodeModel = brixChildren.get(i);
var cmodel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, brixNodeModel, this.getMindmap());
actionDispatcher.deleteTopics([cmodel.getId()]);
}
} catch(e) {
console.trace();
console.log(e);
}
}.bind(this));
this._brixModel.__registered = true;
}
},
@@ -106,7 +108,7 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
},
getPropertiesKeys : function() {
return this._brixModel.getKeys();
return this._brixModel.getKeys().erase('children');
},
getParent : function() {