mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 06:37:56 +01:00
Improve save logic.
This commit is contained in:
parent
eaaf3c5d44
commit
8d03aa4095
@ -33,8 +33,6 @@ import { $msg } from '@wisemapping/mindplot';
|
|||||||
class Menu extends IMenu {
|
class Menu extends IMenu {
|
||||||
constructor(designer: Designer, containerId: string, readOnly = false, baseUrl = '') {
|
constructor(designer: Designer, containerId: string, readOnly = false, baseUrl = '') {
|
||||||
super(designer, containerId);
|
super(designer, containerId);
|
||||||
const saveElem = $('#save');
|
|
||||||
|
|
||||||
const widgetsBaseUrl = `${baseUrl}css/widget`;
|
const widgetsBaseUrl = `${baseUrl}css/widget`;
|
||||||
|
|
||||||
// Create panels ...
|
// Create panels ...
|
||||||
@ -274,30 +272,31 @@ class Menu extends IMenu {
|
|||||||
Menu._registerTooltip('fontItalic', $msg('FONT_ITALIC'), 'meta+I');
|
Menu._registerTooltip('fontItalic', $msg('FONT_ITALIC'), 'meta+I');
|
||||||
|
|
||||||
|
|
||||||
if (saveElem) {
|
if (!readOnly) {
|
||||||
|
// Register action on save ...
|
||||||
|
const saveElem = $('#save');
|
||||||
this._addButton('save', false, false,
|
this._addButton('save', false, false,
|
||||||
() => {
|
() => {
|
||||||
this.save(saveElem, designer, true);
|
this.save(saveElem, designer, true);
|
||||||
});
|
});
|
||||||
Menu._registerTooltip('save', $msg('SAVE'), 'meta+S');
|
Menu._registerTooltip('save', $msg('SAVE'), 'meta+S');
|
||||||
|
|
||||||
if (!readOnly) {
|
// Register unload save ...
|
||||||
window.addEventListener('beforeunload', () => {
|
window.addEventListener('beforeunload', () => {
|
||||||
|
if (this.isSaveRequired()) {
|
||||||
|
this.save(saveElem, designer, false);
|
||||||
|
}
|
||||||
|
this.unlockMap(designer);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Autosave on a fixed period of time ...
|
||||||
|
setInterval(
|
||||||
|
() => {
|
||||||
if (this.isSaveRequired()) {
|
if (this.isSaveRequired()) {
|
||||||
this.save(saveElem, designer, false);
|
this.save(saveElem, designer, false);
|
||||||
}
|
}
|
||||||
this.unlockMap(designer);
|
}, 10000,
|
||||||
});
|
);
|
||||||
|
|
||||||
// Autosave on a fixed period of time ...
|
|
||||||
setInterval(
|
|
||||||
() => {
|
|
||||||
if (this.isSaveRequired()) {
|
|
||||||
this.save(saveElem, designer, false);
|
|
||||||
}
|
|
||||||
}, 10000,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,13 @@ class LocalStorageManager extends PersistenceManager {
|
|||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveMapXml(mapId: string, mapDoc: Document): void {
|
saveMapXml(mapId: string, mapDoc: Document, _pref: string, _saveHistory: boolean, events): void {
|
||||||
const mapXml = new XMLSerializer().serializeToString(mapDoc);
|
const mapXml = new XMLSerializer().serializeToString(mapDoc);
|
||||||
if (!this.readOnly) {
|
if (!this.readOnly) {
|
||||||
localStorage.setItem(`${mapId}-xml`, mapXml);
|
localStorage.setItem(`${mapId}-xml`, mapXml);
|
||||||
|
events.onSuccess();
|
||||||
}
|
}
|
||||||
console.log(`Map XML to save => ${this.saveMapXml}`);
|
console.log(`Map XML to save => ${mapXml}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
discardChanges(mapId: string) {
|
discardChanges(mapId: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user