mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17: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 ...
|
// Register keyboard events ...
|
||||||
mindplot.DesignerKeyboard.register(this);
|
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() {
|
_registerMouseEvents : function() {
|
||||||
|
@ -61,6 +61,10 @@ mindplot.PersitenceManager = new Class({
|
|||||||
|
|
||||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(mapDom);
|
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(mapDom);
|
||||||
return serializer.loadFromDom(mapDom, mapId);
|
return serializer.loadFromDom(mapDom, mapId);
|
||||||
|
},
|
||||||
|
|
||||||
|
logEntry: function(severity, message) {
|
||||||
|
throw "Method must be implemented";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
mindplot.commands.DeleteCommand = new Class({
|
mindplot.commands.DeleteCommand = new Class({
|
||||||
Extends:mindplot.Command,
|
Extends:mindplot.Command,
|
||||||
initialize: function(topicIds,relIds) {
|
initialize: function(topicIds, relIds) {
|
||||||
this._relIds = relIds;
|
this._relIds = relIds;
|
||||||
this._topicIds = topicIds;
|
this._topicIds = topicIds;
|
||||||
this._deletedTopicModels = [];
|
this._deletedTopicModels = [];
|
||||||
@ -32,9 +32,9 @@ mindplot.commands.DeleteCommand = new Class({
|
|||||||
if (topics.length > 0) {
|
if (topics.length > 0) {
|
||||||
topics.forEach(
|
topics.forEach(
|
||||||
function(topic, index) {
|
function(topic, index) {
|
||||||
var model = topic.getModel().clone();
|
var model = topic.getModel();
|
||||||
|
|
||||||
//delete relationships
|
// Delete relationships
|
||||||
var relationships = topic.getRelationships();
|
var relationships = topic.getRelationships();
|
||||||
while (relationships.length > 0) {
|
while (relationships.length > 0) {
|
||||||
var relationship = relationships[0];
|
var relationship = relationships[0];
|
||||||
@ -68,6 +68,7 @@ mindplot.commands.DeleteCommand = new Class({
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
undoExecute: function(commandContext) {
|
undoExecute: function(commandContext) {
|
||||||
|
|
||||||
var topics = commandContext.findTopics(this._topicIds);
|
var topics = commandContext.findTopics(this._topicIds);
|
||||||
|
@ -245,27 +245,24 @@ mindplot.widget.Menu = new Class({
|
|||||||
var saveElem = $('save');
|
var saveElem = $('save');
|
||||||
if (saveElem) {
|
if (saveElem) {
|
||||||
this.addButton('save', false, false, function() {
|
this.addButton('save', false, false, function() {
|
||||||
|
this._save(saveElem, designer, true);
|
||||||
|
});
|
||||||
|
|
||||||
$notify("Saving ...");
|
if (!readOnly) {
|
||||||
saveElem.setStyle('cursor', 'wait');
|
// To prevent the user from leaving the page with changes ...
|
||||||
|
$(window).addEvent('beforeunload', function () {
|
||||||
// Load map content ...
|
if (designer.needsSave()) {
|
||||||
var mindmap = designer.getMindmap();
|
this._save(saveElem, designer, false);
|
||||||
var mindmapProp = designer.getMindmapProperties();
|
}
|
||||||
|
}.bind(this));
|
||||||
var persistenceManager = mindplot.PersitenceManager.getInstance();
|
|
||||||
persistenceManager.save(mindmap, mindmapProp, true, {
|
// Autosave on a fixed period of time ...
|
||||||
onSuccess: function() {
|
(function() {
|
||||||
saveElem.setStyle('cursor', 'pointer');
|
if (designer.needsSave()) {
|
||||||
$notify("Save complete");
|
this._save(saveElem, designer, false);
|
||||||
|
}
|
||||||
},
|
}.bind(this)).periodical(30000);
|
||||||
onError: function() {
|
|
||||||
saveElem.setStyle('cursor', 'pointer');
|
|
||||||
$notify("Save could not be completed. Try latter");
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var discardElem = $('discard');
|
var discardElem = $('discard');
|
||||||
@ -436,5 +433,38 @@ mindplot.widget.Menu = new Class({
|
|||||||
this._toolbarElems.forEach(function(item) {
|
this._toolbarElems.forEach(function(item) {
|
||||||
item.hide();
|
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);
|
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.
|
// If a node has focus, focus can be move to another node using the keys.
|
||||||
designer._cleanScreen = function() {
|
designer._cleanScreen = function() {
|
||||||
menu.clear()
|
menu.clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user