mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 06:37:56 +01:00
Disable local storage on embedded view
This commit is contained in:
parent
7c03d04a19
commit
d32eaf63cf
@ -23,23 +23,34 @@ class LocalStorageManager extends PersistenceManager {
|
|||||||
|
|
||||||
private forceLoad: boolean;
|
private forceLoad: boolean;
|
||||||
|
|
||||||
constructor(documentUrl: string, forceLoad: boolean) {
|
private readOnly: boolean;
|
||||||
|
|
||||||
|
constructor(documentUrl: string, forceLoad: boolean, readOnly = true) {
|
||||||
super();
|
super();
|
||||||
this.documentUrl = documentUrl;
|
this.documentUrl = documentUrl;
|
||||||
this.forceLoad = forceLoad;
|
this.forceLoad = forceLoad;
|
||||||
|
this.readOnly = readOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveMapXml(mapId: string, mapDoc: Document): void {
|
saveMapXml(mapId: string, mapDoc: Document): void {
|
||||||
const mapXml = new XMLSerializer().serializeToString(mapDoc);
|
const mapXml = new XMLSerializer().serializeToString(mapDoc);
|
||||||
localStorage.setItem(`${mapId}-xml`, mapXml);
|
if (!this.readOnly) {
|
||||||
|
localStorage.setItem(`${mapId}-xml`, mapXml);
|
||||||
|
}
|
||||||
|
console.log(`Map XML to save => ${this.saveMapXml}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
discardChanges(mapId: string) {
|
discardChanges(mapId: string) {
|
||||||
localStorage.removeItem(`${mapId}-xml`);
|
if (!this.readOnly) {
|
||||||
|
localStorage.removeItem(`${mapId}-xml`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMapDom(mapId: string) {
|
loadMapDom(mapId: string) {
|
||||||
let xml = localStorage.getItem(`${mapId}-xml`);
|
let xml;
|
||||||
|
if (!this.readOnly) {
|
||||||
|
xml = localStorage.getItem(`${mapId}-xml`);
|
||||||
|
}
|
||||||
if (xml == null || this.forceLoad) {
|
if (xml == null || this.forceLoad) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.documentUrl.replace('{id}', mapId),
|
url: this.documentUrl.replace('{id}', mapId),
|
||||||
|
@ -47,12 +47,12 @@ export const fetchMapById = (id: number): MapLoadResult => {
|
|||||||
return client.fetchAllMaps();
|
return client.fetchAllMaps();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Sanitize error structure ...
|
||||||
let errorMsg: ErrorInfo = Object.keys(error).length !== 0 ? error : null;
|
let errorMsg: ErrorInfo = Object.keys(error).length !== 0 ? error : null;
|
||||||
|
|
||||||
|
// If the map can not be loaded, create an error object.
|
||||||
let map: MapInfo;
|
let map: MapInfo;
|
||||||
if (!isLoading) {
|
if (!isLoading) {
|
||||||
// Sanitize error structure ...
|
|
||||||
|
|
||||||
// If the map can not be loaded, create an error object.
|
|
||||||
map = data?.find((m) => m.id == id);
|
map = data?.find((m) => m.id == id);
|
||||||
if (map === null && !errorMsg) {
|
if (map === null && !errorMsg) {
|
||||||
errorMsg = { msg: `Map with id ${id} could not be found. Please, reflesh the page` }
|
errorMsg = { msg: `Map with id ${id} could not be found. Please, reflesh the page` }
|
||||||
|
Loading…
Reference in New Issue
Block a user