mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
- Fix auto save.
- Fix error trying to remove a node that contains a icons - Fix auto-save leaving the page.
This commit is contained in:
parent
c598c1837e
commit
81f9ffa5e9
@ -60,13 +60,6 @@ mindplot.Designer = new Class({
|
||||
|
||||
// Register keyboard events ...
|
||||
mindplot.DesignerKeyboard.register(this);
|
||||
|
||||
// To prevent the user from leaving the page with changes ...
|
||||
$(window).addEvent('beforeunload', function () {
|
||||
if (this.needsSave()) {
|
||||
this.save(null, false);
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_registerMouseEvents : function() {
|
||||
|
@ -61,6 +61,10 @@ mindplot.PersitenceManager = new Class({
|
||||
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(mapDom);
|
||||
return serializer.loadFromDom(mapDom, mapId);
|
||||
},
|
||||
|
||||
logEntry: function(severity, message) {
|
||||
throw "Method must be implemented";
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
mindplot.commands.DeleteCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicIds,relIds) {
|
||||
initialize: function(topicIds, relIds) {
|
||||
this._relIds = relIds;
|
||||
this._topicIds = topicIds;
|
||||
this._deletedTopicModels = [];
|
||||
@ -32,9 +32,9 @@ mindplot.commands.DeleteCommand = new Class({
|
||||
if (topics.length > 0) {
|
||||
topics.forEach(
|
||||
function(topic, index) {
|
||||
var model = topic.getModel().clone();
|
||||
var model = topic.getModel();
|
||||
|
||||
//delete relationships
|
||||
// Delete relationships
|
||||
var relationships = topic.getRelationships();
|
||||
while (relationships.length > 0) {
|
||||
var relationship = relationships[0];
|
||||
@ -68,6 +68,7 @@ mindplot.commands.DeleteCommand = new Class({
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
|
||||
var topics = commandContext.findTopics(this._topicIds);
|
||||
|
@ -245,27 +245,24 @@ mindplot.widget.Menu = new Class({
|
||||
var saveElem = $('save');
|
||||
if (saveElem) {
|
||||
this.addButton('save', false, false, function() {
|
||||
|
||||
$notify("Saving ...");
|
||||
saveElem.setStyle('cursor', 'wait');
|
||||
|
||||
// Load map content ...
|
||||
var mindmap = designer.getMindmap();
|
||||
var mindmapProp = designer.getMindmapProperties();
|
||||
|
||||
var persistenceManager = mindplot.PersitenceManager.getInstance();
|
||||
persistenceManager.save(mindmap, mindmapProp, true, {
|
||||
onSuccess: function() {
|
||||
saveElem.setStyle('cursor', 'pointer');
|
||||
$notify("Save complete");
|
||||
|
||||
},
|
||||
onError: function() {
|
||||
saveElem.setStyle('cursor', 'pointer');
|
||||
$notify("Save could not be completed. Try latter");
|
||||
}
|
||||
});
|
||||
this._save(saveElem, designer, true);
|
||||
});
|
||||
|
||||
if (!readOnly) {
|
||||
// To prevent the user from leaving the page with changes ...
|
||||
$(window).addEvent('beforeunload', function () {
|
||||
if (designer.needsSave()) {
|
||||
this._save(saveElem, designer, false);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
// Autosave on a fixed period of time ...
|
||||
(function() {
|
||||
if (designer.needsSave()) {
|
||||
this._save(saveElem, designer, false);
|
||||
}
|
||||
}.bind(this)).periodical(30000);
|
||||
}
|
||||
}
|
||||
|
||||
var discardElem = $('discard');
|
||||
@ -436,5 +433,38 @@ mindplot.widget.Menu = new Class({
|
||||
this._toolbarElems.forEach(function(item) {
|
||||
item.hide();
|
||||
});
|
||||
},
|
||||
|
||||
_save:function (saveElem, designer, saveHistory) {
|
||||
|
||||
// Load map content ...
|
||||
var mindmap = designer.getMindmap();
|
||||
var mindmapProp = designer.getMindmapProperties();
|
||||
|
||||
// Display save message ..
|
||||
if (saveHistory) {
|
||||
$notify("Saving ...");
|
||||
saveElem.setStyle('cursor', 'wait');
|
||||
} else {
|
||||
console.log("Saving without history ...");
|
||||
}
|
||||
|
||||
// Call persistence manager for saving ...
|
||||
var persistenceManager = mindplot.PersitenceManager.getInstance();
|
||||
persistenceManager.save(mindmap, mindmapProp, saveHistory, {
|
||||
onSuccess: function() {
|
||||
if (saveHistory) {
|
||||
saveElem.setStyle('cursor', 'pointer');
|
||||
$notify("Save complete");
|
||||
}
|
||||
},
|
||||
onError: function() {
|
||||
if (saveHistory) {
|
||||
saveElem.setStyle('cursor', 'pointer');
|
||||
$notify("Save could not be completed. Try latter");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
@ -29,25 +29,6 @@ function setUpToolbar(designer, readOnly) {
|
||||
|
||||
var menu = new mindplot.widget.Menu(designer, 'toolbar', mapId);
|
||||
|
||||
// Autosave ...
|
||||
if (!readOnly) {
|
||||
(function() {
|
||||
|
||||
if (designer.needsSave()) {
|
||||
designer.save(function() {
|
||||
var monitor = core.ToolbarNotifier.getInstance();
|
||||
}, false);
|
||||
}
|
||||
}).periodical(30000);
|
||||
|
||||
// To prevent the user from leaving the page with changes ...
|
||||
window.onbeforeunload = function() {
|
||||
if (designer.needsSave()) {
|
||||
designer.save(null, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If a node has focus, focus can be move to another node using the keys.
|
||||
designer._cleanScreen = function() {
|
||||
menu.clear()
|
||||
|
Loading…
Reference in New Issue
Block a user