Save action working again :).
This commit is contained in:
@@ -25,9 +25,9 @@ mindplot.Beta2PelaMigrator = new Class({
|
||||
return this._pelaSerializer.toXML(mindmap);
|
||||
},
|
||||
|
||||
loadFromDom : function(dom,mapId) {
|
||||
$assert($defined(mapId),"mapId can not be null");
|
||||
var mindmap = this._betaSerializer.loadFromDom(dom);
|
||||
loadFromDom : function(dom, mapId) {
|
||||
$assert($defined(mapId), "mapId can not be null");
|
||||
var mindmap = this._betaSerializer.loadFromDom(dom, mapId);
|
||||
mindmap.setVersion(mindplot.ModelCodeName.PELA);
|
||||
return mindmap;
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ mindplot.DesignerActionRunner = new Class({
|
||||
markAsChangeBase: function() {
|
||||
return this._undoManager.markAsChangeBase();
|
||||
},
|
||||
|
||||
hasBeenChanged: function() {
|
||||
return this._undoManager.hasBeenChanged();
|
||||
}
|
||||
|
@@ -61,9 +61,9 @@ mindplot.MindmapDesigner = new Class({
|
||||
|
||||
// To prevent the user from leaving the page with changes ...
|
||||
$(window).addEvent('beforeunload', function () {
|
||||
// if (this.needsSave()) {
|
||||
// this.save(null, false)
|
||||
// }
|
||||
if (this.needsSave()) {
|
||||
this.save(null, false);
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
@@ -360,19 +360,24 @@ mindplot.MindmapDesigner = new Class({
|
||||
},
|
||||
|
||||
needsSave : function() {
|
||||
return this._actionRunner.hasBeenChanged();
|
||||
|
||||
//@Todo: Review all this ...
|
||||
// return this._actionDispatcher.hasBeenChanged();
|
||||
return true;
|
||||
},
|
||||
|
||||
save : function(onSavedHandler, saveHistory) {
|
||||
var persistantManager = mindplot.PersistanceManager;
|
||||
var mindmap = this._mindmap;
|
||||
|
||||
var mindmap = this.getMindmap();
|
||||
var properties = {zoom:this.getModel().getZoom(), layoutManager:this._layoutManager.getClassName()};
|
||||
|
||||
var persistantManager = mindplot.PersistanceManager;
|
||||
persistantManager.save(mindmap, properties, onSavedHandler, saveHistory);
|
||||
this.fireEvent("save", {type:saveHistory});
|
||||
|
||||
// Refresh undo state...
|
||||
this._actionRunner.markAsChangeBase();
|
||||
//@Todo: Review all this. It should not be here ...
|
||||
|
||||
// this._actionDispatcher.markAsChangeBase();
|
||||
},
|
||||
|
||||
|
||||
|
@@ -1,73 +1,69 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.PersistanceManager = {};
|
||||
|
||||
mindplot.PersistanceManager.save = function(mindmap, editorProperties, onSavedHandler,saveHistory)
|
||||
{
|
||||
mindplot.PersistanceManager.save = function(mindmap, editorProperties, onSavedHandler, saveHistory) {
|
||||
$assert(mindmap, "mindmap can not be null");
|
||||
$assert(editorProperties, "editorProperties can not be null");
|
||||
|
||||
var mapId = mindmap.getId();
|
||||
$assert(mapId, "mapId can not be null");
|
||||
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||
var xmlMap = serializer.toXML(mindmap);
|
||||
var xmlMapStr = core.Utils.innerXML(xmlMap);
|
||||
|
||||
var pref = JSON.toString(editorProperties);
|
||||
window.MapEditorService.saveMap(mapId, xmlMapStr, pref,saveHistory,
|
||||
{
|
||||
callback:function(response) {
|
||||
var pref = JSON.encode(editorProperties);
|
||||
|
||||
if (response.msgCode != "OK")
|
||||
{
|
||||
monitor.logError("Save could not be completed. Please,try again in a couple of minutes.");
|
||||
window.MapEditorService.saveMap(mapId, xmlMapStr, pref, saveHistory,
|
||||
{
|
||||
callback:function(response) {
|
||||
|
||||
if (response.msgCode != "OK") {
|
||||
monitor.logError("Save could not be completed. Please,try again in a couple of minutes.");
|
||||
// wLogger.error(response.msgDetails);
|
||||
} else
|
||||
{
|
||||
// Execute on success handler ...
|
||||
if ($defined(onSavedHandler))
|
||||
{
|
||||
onSavedHandler();
|
||||
} else {
|
||||
// Execute on success handler ...
|
||||
if ($defined(onSavedHandler)) {
|
||||
onSavedHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
errorHandler:function(message) {
|
||||
var monitor = core.Monitor.getInstance();
|
||||
monitor.logError("Save could not be completed. Please,try again in a couple of minutes.");
|
||||
},
|
||||
errorHandler:function(message) {
|
||||
var monitor = core.Monitor.getInstance();
|
||||
monitor.logError("Save could not be completed. Please,try again in a couple of minutes.");
|
||||
// wLogger.error(message);
|
||||
},
|
||||
verb:"POST",
|
||||
async: false
|
||||
});
|
||||
},
|
||||
verb:"POST",
|
||||
async: false
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
mindplot.PersistanceManager.load = function(mapId)
|
||||
{
|
||||
mindplot.PersistanceManager.load = function(mapId) {
|
||||
$assert(mapId, "mapId can not be null");
|
||||
|
||||
var result = {r:null};
|
||||
window.MapEditorService.loadMap(mapId, {
|
||||
callback:function(response) {
|
||||
|
||||
if (response.msgCode == "OK")
|
||||
{
|
||||
if (response.msgCode == "OK") {
|
||||
// Explorer Hack with local files ...
|
||||
var xmlContent = response.content;
|
||||
var domDocument = core.Utils.createDocumentFromText(xmlContent);
|
||||
@@ -76,8 +72,7 @@ mindplot.PersistanceManager.load = function(mapId)
|
||||
mindmap.setId(mapId);
|
||||
|
||||
result.r = mindmap;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
// Handle error message ...
|
||||
var msg = response.msgDetails;
|
||||
var monitor = core.Monitor.getInstance();
|
||||
|
@@ -157,8 +157,10 @@ mindplot.XMLMindmapSerializer_Beta = new Class({
|
||||
return noteDom;
|
||||
},
|
||||
|
||||
loadFromDom : function(dom) {
|
||||
loadFromDom : function(dom, mapId) {
|
||||
$assert(dom, "Dom can not be null");
|
||||
$assert(mapId, "mapId can not be null");
|
||||
|
||||
var rootElem = dom.documentElement;
|
||||
|
||||
// Is a wisemap?.
|
||||
@@ -175,6 +177,7 @@ mindplot.XMLMindmapSerializer_Beta = new Class({
|
||||
mindmap.addBranch(topic);
|
||||
}
|
||||
}
|
||||
mindmap.setId(mapId);
|
||||
return mindmap;
|
||||
},
|
||||
|
||||
|
@@ -198,8 +198,10 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
||||
return relationDom;
|
||||
},
|
||||
|
||||
loadFromDom : function(dom) {
|
||||
$assert(dom, "Dom can not be null");
|
||||
loadFromDom : function(dom, mapId) {
|
||||
$assert(dom, "dom can not be null");
|
||||
$assert(mapId, "mapId can not be null");
|
||||
|
||||
var rootElem = dom.documentElement;
|
||||
|
||||
// Is a wisemap?.
|
||||
@@ -230,6 +232,7 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
||||
}
|
||||
}
|
||||
this._idsMap = null;
|
||||
mindmap.setId(mapId);
|
||||
return mindmap;
|
||||
},
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
mindplot.widget.Menu = new Class({
|
||||
initialize : function(designer, containerId) {
|
||||
initialize : function(designer, containerId, readOnly) {
|
||||
$assert(designer, "designer can not be null");
|
||||
$assert(containerId, "containerId can not be null");
|
||||
// @Todo: Remove hardcode ...
|
||||
@@ -256,6 +256,89 @@ mindplot.widget.Menu = new Class({
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var saveElem = $('saveButton');
|
||||
if (saveElem) {
|
||||
saveElem.addEvent('click', function() {
|
||||
|
||||
if (!readOnly) {
|
||||
$('saveButton').setStyle('cursor', 'wait');
|
||||
(function() {
|
||||
designer.save(function() {
|
||||
// var monitor = core.Monitor.getInstance();
|
||||
// monitor.logMessage('Save completed successfully');
|
||||
|
||||
saveElem.setStyle('cursor', 'pointer');
|
||||
}, true);
|
||||
}).delay(1);
|
||||
} else {
|
||||
new Windoo.Confirm('This option is not enabled in try mode. You must by signed in order to execute this action.<br/> to create an account click <a href="userRegistration.htm">here</a>',
|
||||
{
|
||||
'window': {theme:Windoo.Themes.wise,
|
||||
title:''
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var discartElem = $('discartElem');
|
||||
if (discartElem) {
|
||||
discartElem.addEvent('click', function() {
|
||||
|
||||
if (!readOnly) {
|
||||
displayLoading();
|
||||
window.document.location = "mymaps.htm";
|
||||
} else {
|
||||
displayLoading();
|
||||
window.document.location = "home.htm";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (readOnly) {
|
||||
$('tagIt').addEvent('click', function(event) {
|
||||
new Windoo.Confirm('This option is not enabled in try mode. You must by signed in order to execute this action.',
|
||||
{
|
||||
'window': {theme:Windoo.Themes.wise,
|
||||
title:''
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('shareIt').addEvent('click', function(event) {
|
||||
new Windoo.Confirm('This option is not enabled in try mode. You must by signed in order to execute this action.',
|
||||
{
|
||||
'window': {theme:Windoo.Themes.wise,
|
||||
title:''
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('publishIt').addEvent('click', function(event) {
|
||||
new Windoo.Confirm('This option is not enabled in try mode. You must by signed in order to execute this action.',
|
||||
{
|
||||
'window': {theme:Windoo.Themes.wise,
|
||||
title:''
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('history').addEvent('click', function(event) {
|
||||
new Windoo.Confirm('This option is not enabled in try mode. You must by signed in order to execute this action.',
|
||||
{
|
||||
'window': {theme:Windoo.Themes.wise,
|
||||
title:''
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
clear : function() {
|
||||
|
Reference in New Issue
Block a user