Commit 4c18ff64 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

closing submap window triggers cleaning remembered opened submap

parent 28f3d0ea
Pipeline #9558 passed with stage
in 12 minutes and 53 seconds
......@@ -3,6 +3,7 @@ minerva (12.2.1) stable; urgency=medium
read colors properly) (#744)
* Bug fix: removing active plugin didn't switch plugin tab to the next loaded
plugin (#757)
* Bug fix: closed submap will not be reopened after page refresh (#763)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 1 Apr 2019 17:00:00 +0200
......
......@@ -46,6 +46,7 @@ function CustomMap(options) {
this.registerListenerType("onHideOverlay");
this.registerListenerType("onBackgroundOverlayChange");
this.registerListenerType("onSubmapOpen");
this.registerListenerType("onSubmapClose");
// @type {boolean[]}
this._selectedOverlays = [];
......@@ -143,9 +144,14 @@ CustomMap.prototype.init = function () {
* Create submaps.
*/
CustomMap.prototype.createSubmaps = function () {
this.submaps = [];
for (var i = 1; i < this.getProject().getModels().length; i++) {
this.submaps.push(new Submap(this, this.getProject().getModels()[i]));
var self = this;
self.submaps = [];
for (var i = 1; i < self.getProject().getModels().length; i++) {
var submap = new Submap(self, self.getProject().getModels()[i]);
submap.addListener("onClose", function (event) {
return self.callListeners("onSubmapClose", {mapId: event.object.getId()});
});
self.submaps.push(submap);
}
};
......
......@@ -372,6 +372,9 @@ function addUrlChangeListenersToCustomMap(customMap) {
customMap.addListener("onSubmapOpen", function (event) {
GuiConnector.setUrlParam("submap", event.arg.mapId.toString());
});
customMap.addListener("onSubmapClose", function (event) {
GuiConnector.setUrlParam("submap", undefined);
});
var onCenterChangedHandler = function (event) {
if (event.object.getId() !== customMap.getId()) {
GuiConnector.setUrlParam("submap", event.object.getId().toString());
......
......@@ -6,6 +6,7 @@ var Promise = require("bluebird");
var minerva = require('../../main/js/minerva');
var ConfigurationType = require('../../main/js/ConfigurationType');
var GuiConnector = require('../../main/js/GuiConnector');
var SecurityError = require('../../main/js/SecurityError');
var ServerConnectorMock = require('./ServerConnector-mock');
var Point = require('../../main/js/map/canvas/Point');
......@@ -340,7 +341,7 @@ describe('minerva global', function () {
it('plugin onFocus functionality', function () {
helper.setUrl("http://test/?search=s1");
var globalObject, plugin, callbackCalled=false;
var globalObject, plugin, callbackCalled = false;
return ServerConnectorMock.getProject().then(function (project) {
var options = helper.createCustomMapOptions(project);
plugin = new ProxyAccessPlugin();
......@@ -361,4 +362,29 @@ describe('minerva global', function () {
});
describe("close submap", function () {
it("check if url parameters changed", function () {
var data;
var map;
var submapId = 16729;
var submapParameter;
var projectId = "complex_model_with_submaps";
return ServerConnectorMock.getProject(projectId).then(function (project) {
var options = helper.createCustomMapOptions(project);
options.setDebug(true);
return minerva.create(options);
}).then(function (result) {
data = result;
map = result.customMap;
return map.openSubmap(submapId);
}).then(function () {
submapParameter = GuiConnector.getParams["submap"];
return map.getSubmapById(submapId).close();
}).then(function () {
assert.notEqual(GuiConnector.getParams["submap"], submapParameter, "Submap parameter should change after submap was closed");
return data.destroy();
})
});
});
});
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