mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-12 07:10:07 +02: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() {
|
||||||
|
@ -1,74 +1,78 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright [2011] [wisemapping]
|
* Copyright [2011] [wisemapping]
|
||||||
*
|
*
|
||||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
* "powered by wisemapping" text requirement on every single page;
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the license at
|
* You may obtain a copy of the license at
|
||||||
*
|
*
|
||||||
* http://www.wisemapping.org/license
|
* http://www.wisemapping.org/license
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.PersitenceManager = new Class({
|
mindplot.PersitenceManager = new Class({
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function(mindmap, editorProperties, saveHistory, events) {
|
save: function(mindmap, editorProperties, saveHistory, events) {
|
||||||
$assert(mindmap, "mindmap can not be null");
|
$assert(mindmap, "mindmap can not be null");
|
||||||
$assert(editorProperties, "editorProperties can not be null");
|
$assert(editorProperties, "editorProperties can not be null");
|
||||||
|
|
||||||
var mapId = mindmap.getId();
|
var mapId = mindmap.getId();
|
||||||
$assert(mapId, "mapId can not be null");
|
$assert(mapId, "mapId can not be null");
|
||||||
|
|
||||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap(mindmap);
|
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||||
var domMap = serializer.toXML(mindmap);
|
var domMap = serializer.toXML(mindmap);
|
||||||
var mapXml = core.Utils.innerXML(domMap);
|
var mapXml = core.Utils.innerXML(domMap);
|
||||||
|
|
||||||
var pref = JSON.encode(editorProperties);
|
var pref = JSON.encode(editorProperties);
|
||||||
try {
|
try {
|
||||||
this.saveMapXml(mapId, mapXml, pref, saveHistory, events);
|
this.saveMapXml(mapId, mapXml, pref, saveHistory, events);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
events.onError();
|
events.onError();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
load: function(mapId) {
|
load: function(mapId) {
|
||||||
$assert(mapId, "mapId can not be null");
|
$assert(mapId, "mapId can not be null");
|
||||||
var domDocument = this.loadMapDom(mapId);
|
var domDocument = this.loadMapDom(mapId);
|
||||||
return this.loadFromDom(mapId, domDocument);
|
return this.loadFromDom(mapId, domDocument);
|
||||||
},
|
},
|
||||||
|
|
||||||
loadMapDom: function(mapId) {
|
loadMapDom: function(mapId) {
|
||||||
throw "Method must be implemented";
|
throw "Method must be implemented";
|
||||||
},
|
},
|
||||||
|
|
||||||
saveMapXml : function(mapId, mapXml, pref, saveHistory, events) {
|
saveMapXml : function(mapId, mapXml, pref, saveHistory, events) {
|
||||||
throw "Method must be implemented";
|
throw "Method must be implemented";
|
||||||
},
|
},
|
||||||
|
|
||||||
loadFromDom : function(mapId, mapDom) {
|
loadFromDom : function(mapId, mapDom) {
|
||||||
$assert(mapId, "mapId can not be null");
|
$assert(mapId, "mapId can not be null");
|
||||||
$assert(mapDom, "mapDom can not be null");
|
$assert(mapDom, "mapDom can not be null");
|
||||||
|
|
||||||
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) {
|
||||||
mindplot.PersitenceManager.init = function(instance) {
|
throw "Method must be implemented";
|
||||||
mindplot.PersitenceManager._instance = instance;
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
mindplot.PersitenceManager.getInstance = function() {
|
mindplot.PersitenceManager.init = function(instance) {
|
||||||
return mindplot.PersitenceManager._instance;
|
mindplot.PersitenceManager._instance = instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mindplot.PersitenceManager.getInstance = function() {
|
||||||
|
return mindplot.PersitenceManager._instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
@ -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 ...");
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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');
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
@ -1,79 +1,60 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright [2011] [wisemapping]
|
* Copyright [2011] [wisemapping]
|
||||||
*
|
*
|
||||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
* "powered by wisemapping" text requirement on every single page;
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the license at
|
* You may obtain a copy of the license at
|
||||||
*
|
*
|
||||||
* http://www.wisemapping.org/license
|
* http://www.wisemapping.org/license
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
Asset.javascript('../js/mindplot-min.js', {
|
Asset.javascript('../js/mindplot-min.js', {
|
||||||
id: 'MindplotSVGLib',
|
id: 'MindplotSVGLib',
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
$(document).fireEvent('loadcomplete', 'mind')
|
$(document).fireEvent('loadcomplete', 'mind')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var designer = null;
|
var designer = null;
|
||||||
/* JavaScript tabs changer */
|
/* JavaScript tabs changer */
|
||||||
|
|
||||||
function setUpToolbar(designer, readOnly) {
|
function setUpToolbar(designer, readOnly) {
|
||||||
|
|
||||||
var menu = new mindplot.widget.Menu(designer, 'toolbar', mapId);
|
var menu = new mindplot.widget.Menu(designer, 'toolbar', mapId);
|
||||||
|
|
||||||
// Autosave ...
|
// If a node has focus, focus can be move to another node using the keys.
|
||||||
if (!readOnly) {
|
designer._cleanScreen = function() {
|
||||||
(function() {
|
menu.clear()
|
||||||
|
};
|
||||||
if (designer.needsSave()) {
|
|
||||||
designer.save(function() {
|
|
||||||
var monitor = core.ToolbarNotifier.getInstance();
|
}
|
||||||
}, false);
|
|
||||||
}
|
function buildDesigner(properties) {
|
||||||
}).periodical(30000);
|
$assert(properties, "properties can not be null");
|
||||||
|
|
||||||
// To prevent the user from leaving the page with changes ...
|
var container = $('mindplot');
|
||||||
window.onbeforeunload = function() {
|
container.setStyles({
|
||||||
if (designer.needsSave()) {
|
height: parseInt(screen.height),
|
||||||
designer.save(null, false)
|
width: parseInt(screen.width)
|
||||||
}
|
});
|
||||||
}
|
|
||||||
}
|
designer = new mindplot.Designer(properties, container);
|
||||||
|
designer.setViewPort({
|
||||||
// If a node has focus, focus can be move to another node using the keys.
|
height: parseInt(window.innerHeight - 151), // Footer and Header
|
||||||
designer._cleanScreen = function() {
|
width: parseInt(window.innerWidth)
|
||||||
menu.clear()
|
});
|
||||||
};
|
|
||||||
|
// Toolbar is only loaded if it was defined ...
|
||||||
|
if ($('toolbar')) {
|
||||||
}
|
setUpToolbar(designer, properties.readOnly);
|
||||||
|
}
|
||||||
function buildDesigner(properties) {
|
return designer;
|
||||||
$assert(properties, "properties can not be null");
|
}
|
||||||
|
|
||||||
var container = $('mindplot');
|
|
||||||
container.setStyles({
|
|
||||||
height: parseInt(screen.height),
|
|
||||||
width: parseInt(screen.width)
|
|
||||||
});
|
|
||||||
|
|
||||||
designer = new mindplot.Designer(properties, container);
|
|
||||||
designer.setViewPort({
|
|
||||||
height: parseInt(window.innerHeight - 151), // Footer and Header
|
|
||||||
width: parseInt(window.innerWidth)
|
|
||||||
});
|
|
||||||
|
|
||||||
// Toolbar is only loaded if it was defined ...
|
|
||||||
if ($('toolbar')) {
|
|
||||||
setUpToolbar(designer, properties.readOnly);
|
|
||||||
}
|
|
||||||
return designer;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user