Commit f573ac5a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

selected background overlay is stored in JS session

parent e45713db
......@@ -49,13 +49,6 @@ ServerConnector.lastActualization = 0;
ServerConnector._customMap = null;
/**
* Set layout that is currently browsed for {@link CustomMap} on the server
* side.
*/
ServerConnector.setSelectedLayout = function(value) {
document.getElementById(ServerConnector.formIdentifier + ':selectedLayout').value = "" + value;
};
/**
* Sets list of layouts visualized by javascript.
*/
......@@ -63,17 +56,6 @@ ServerConnector.setVisibleLayouts = function(value) {
document.getElementById(ServerConnector.formIdentifier + ':visibleLayouts').value = value;
};
/**
* Get layout of the {@link CustomMap} which was last browsed.
*/
ServerConnector.getSelectedLayout = function() {
var result = document.getElementById(ServerConnector.formIdentifier + ':selectedLayout').value;
if (result === undefined) {
result = null;
}
return result;
};
/**
* Sends data about coordinates/zoom level etc. to the server. Method checks if
* the transmition is not done to often (at most once per second)
......
......@@ -29,6 +29,18 @@ SessionData.prototype.setShowComments = function(value) {
Cookies.set(key, value + "");
};
SessionData.prototype.getSelectedBackgroundOverlay = function() {
var key = this.getKey(SessionObjectType.SELECTED_BACKGROUND_OVERLAY);
return Cookies.get(key);
};
SessionData.prototype.setSelectedBackgroundOverlay = function(value) {
var key = this.getKey(SessionObjectType.SELECTED_BACKGROUND_OVERLAY);
Cookies.set(key, value + "");
};
SessionData.prototype.setZoomLevel = function(model, value) {
var key = this.getKey(SessionObjectType.ZOOM_LEVEL, [ model.getId() ]);
Cookies.set(key, value + "");
......
"use strict";
var SessionObjectType = {
CENTER : "CENTER",
SHOW_COMMENT : "SHOW_COMMENT",
SELECTED_BACKGROUND_OVERLAY : "SELECTED_BACKGROUND_OVERLAY",
CENTER : "CENTER",
ZOOM_LEVEL : "ZOOM_LEVEL",
};
......
......@@ -723,13 +723,12 @@ CustomMap.prototype.createMapChangedCallbacks = function() {
// listener for changing type of layout
google.maps.event.addListener(this.getGoogleMap(), 'maptypeid_changed', function() {
ServerConnector.setSelectedLayout(customMapSelf.getGoogleMap().getMapTypeId());
ServerConnector.actualizeParams();
sessionData.setSelectedBackgroundOverlay(customMapSelf.getGoogleMap().getMapTypeId());
});
// if we have type of layout stored in the session then restore it
var mapType = ServerConnector.getSelectedLayout();
if (mapType !== "" && mapType !== null && mapType !== undefined) {
var mapType = sessionData.getSelectedBackgroundOverlay();
if (mapType !== undefined) {
this.openLayout(mapType);
}
};
......
......@@ -11,7 +11,8 @@ var ServerConnectorMock = OriginalServerConnector;
ServerConnectorMock.init = function() {
this._customMap = null;
ServerConnectorMock.selectedLayout = null;
this._sessionData = undefined;
ServerConnectorMock.listeners = [];
ServerConnectorMock.selectedPolygon = null;
......@@ -83,14 +84,6 @@ ServerConnectorMock.callListeners = function(type, param) {
}
};
ServerConnectorMock.setSelectedLayout = function(value) {
this.selectedLayout = value;
};
ServerConnectorMock.getSelectedLayout = function() {
return this.selectedLayout;
};
ServerConnectorMock.setSelectedPolygon = function(value) {
this.selectedPolygon = value;
};
......
......@@ -73,16 +73,16 @@ describe('minerva global', function() {
assert.ok(result);
// input file is not available so it's the background
assert.equal(result.getSelectedLayouts().length, 0);
assert.equal(ServerConnector.getSelectedLayout(), "cv" + layoutId);
assert.equal(ServerConnector.getSessionData(project).getSelectedBackgroundOverlay(), "cv" + layoutId);
assert.equal(logger.getWarnings().length, 1);
});
});
it('create with layout 2', function() {
var project = helper.createProject();
var map = helper.createGoogleMap();
var layout = helper.createLayout();
layout.setInputDataAvailable(true);
// disable upload of the data from server
......
"use strict";
var Promise = require("bluebird");
var Cookies = require('js-cookie');
// GLOBAL configuration
......@@ -24,11 +25,25 @@ global.navigator = {
var logger = require('./logger');
function removeCookies(){
var cookies = Cookies.get();
for(var cookie in cookies) {
Cookies.remove(cookie);
}
}
beforeEach(function() {
Promise.longStackTraces();
logger.flushBuffer();
removeCookies();
ServerConnector.init();
ServerConnector.setToken("MOCK_TOKEN_ID");
GuiConnector.init();
global.testDiv = document.createElement("div");
global.testDiv.id = "test";
document.body.appendChild(testDiv);
......@@ -37,10 +52,6 @@ beforeEach(function() {
global.dialogDiv.id = "feedbackContent";
document.body.appendChild(global.dialogDiv);
ServerConnector.init();
ServerConnector.setToken("MOCK_TOKEN_ID");
GuiConnector.init();
});
after(function() {
......
......@@ -38,7 +38,6 @@
<h:inputHidden id="selectedDrugPolygon" value="#{drugMB.polygon}"/>
<p:remoteCommand name="_actualizeParams" actionListener="#{mapMB.actualizeParams}"/>
<h:inputHidden id="selectedLayout" value="#{mapMB.topModelMapData.selectedLayout}"/>
<h:panelGroup layout="block" id="submodelDialogGroup">
</h:panelGroup>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment