mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-05 07:03:24 +01:00
adding collaborative node text edition
This commit is contained in:
parent
18dfd82c1d
commit
ff8cf207ca
@ -20,6 +20,21 @@ mindplot.BrixActionDispatcher = new Class({
|
||||
Extends: mindplot.ActionDispatcher,
|
||||
initialize: function(commandContext, fireOnChange) {
|
||||
this.parent(commandContext, fireOnChange);
|
||||
this._commandContext = commandContext;
|
||||
this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
|
||||
},
|
||||
|
||||
changeTextOnTopic : function(topicsIds, text) {
|
||||
var framework=$wise_collaborationManager.getCollaborativeFramework();
|
||||
if (!(topicsIds instanceof Array)) {
|
||||
topicsIds = [topicsIds];
|
||||
}
|
||||
var topic = framework.getTopic(topicsIds[0]);
|
||||
var callback = function(event, topic){
|
||||
topic.getBrixModel().removeListener("valueChanged", callback);
|
||||
this._actionDispatcher.changeTextOnTopic(topic.getId(),event.getNewValue());
|
||||
}.bindWithEvent(this,topic);
|
||||
topic.setText(text, true, callback);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -24,7 +24,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
|
||||
// Dispatcher manager ...
|
||||
var commandContext = new mindplot.CommandContext(this);
|
||||
this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
|
||||
this._actionDispatcher = new mindplot.BrixActionDispatcher(commandContext);
|
||||
this._actionDispatcher.addEvent("modelUpdate", function(event) {
|
||||
this._fireEvent("modelUpdate", event);
|
||||
}.bind(this));
|
||||
|
@ -23,6 +23,9 @@ mindplot.collaboration.CollaborationManager = new Class({
|
||||
},
|
||||
buildWiseModel: function(){
|
||||
return this._collaborativeFramework.buildWiseModel();
|
||||
},
|
||||
getCollaborativeFramework:function(){
|
||||
return this._collaborativeFramework;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -7,6 +7,7 @@ mindplot.collaboration.frameworks.AbstractCollaborativeFramework = new Class({
|
||||
model = this._buildInitialCollaborativeModel();
|
||||
}
|
||||
this._model = model;
|
||||
this._actionDispatcher = null;
|
||||
},
|
||||
getModel: function(){
|
||||
return this._model;
|
||||
@ -31,6 +32,22 @@ mindplot.collaboration.frameworks.AbstractCollaborativeFramework = new Class({
|
||||
mindmap.addBranch(centralTopic);
|
||||
return mindmap;
|
||||
},
|
||||
addMindmap:function(model){}
|
||||
addMindmap:function(model){},
|
||||
getTopic:function(id){
|
||||
var branches = this.getModel().getBranches();
|
||||
for(var i = 0; i<branches.length; i++){
|
||||
if(branches[i].getId()==id){
|
||||
return branches[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
getActionDispatcher:function(){
|
||||
if(this._actionDispatcher == null){
|
||||
var context = mindplot.ActionDispatcher.getInstance()._commandContext;
|
||||
this._actionDispatcher = new mindplot.LocalActionDispatcher(context);
|
||||
}
|
||||
return this._actionDispatcher;
|
||||
}
|
||||
|
||||
});
|
@ -29,7 +29,17 @@ mindplot.collaboration.frameworks.brix.model.NodeModel = new Class({
|
||||
this.parent(type, mindmap, id);
|
||||
if(!$defined(this._brixModel)){
|
||||
this._brixModel = this._createBrixModel();
|
||||
}else{
|
||||
var text = this._brixModel.get("text");
|
||||
this.setText(text, false);
|
||||
}
|
||||
this._addBrixListeners();
|
||||
},
|
||||
_addBrixListeners:function(){
|
||||
this._brixModel.addListener("valueChanged", this._valuechangeListener.bindWithEvent(this));
|
||||
},
|
||||
_valuechangeListener:function(event){
|
||||
this._brixFramework.getActionDispatcher().changeTextOnTopic(this.getId(),event.getNewValue());
|
||||
},
|
||||
_createBrixModel:function(){
|
||||
var model = this._brixFramework.getBrixModel().create("Map");
|
||||
@ -100,9 +110,12 @@ mindplot.collaboration.frameworks.brix.model.NodeModel = new Class({
|
||||
return this._type;
|
||||
},
|
||||
|
||||
setText : function(text) {
|
||||
setText : function(text,updateModel, callback) {
|
||||
this.parent(text);
|
||||
this._brixModel.set("text",text);
|
||||
if($defined(updateModel) && updateModel){
|
||||
this._brixModel.addListener("valueChanged",callback);
|
||||
this._brixModel.put("text",text);
|
||||
}
|
||||
},
|
||||
|
||||
getText : function() {
|
||||
|
Loading…
Reference in New Issue
Block a user