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

when opening map without data overlay there was unhandled error

parent 5691acb9
Pipeline #15138 failed with stage
in 12 minutes and 33 seconds
......@@ -11,7 +11,7 @@ minerva (14.0.3) stable; urgency=medium
* Bug fix: refresh button in overlay panel synchronise list of general and
user provided data overlays (#975)
* Bug fix: changing order of data overlays is reflected in info window
* Bug fix: opening map with no available background crashed (#964)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 16 Oct 2019 9:00:00 +0200
......
......@@ -8,6 +8,7 @@ require('datatables.net-rowreorder')();
var AddOverlayDialog = require('../AddOverlayDialog');
var Panel = require('../Panel');
var PanelControlElementType = require('../PanelControlElementType');
var ValidationError = require('../../ValidationError');
var GuiConnector = require('../../GuiConnector');
// noinspection JSUnusedLocalSymbols
......@@ -473,6 +474,9 @@ OverlayPanel.prototype.refresh = function (showDefault) {
self.getProject().addOrUpdateDataOverlays(overlaysFromServer);
if (!showDefault) {
if (overlaysFromServer.length === 0) {
return Promise.reject(new ValidationError("Project doesn't have a background defined. Please re-upload map in admin panel."));
}
var id = self.getMap().getBackgroundDataOverlay().getId();
selectedOverlay[id] = true;
}
......
......@@ -19,6 +19,7 @@ var Reaction = require('./data/Reaction');
var ReferenceGenome = require('./data/ReferenceGenome');
var SecurityError = require('../SecurityError');
var Submap = require('./Submap');
var ValidationError = require('../ValidationError');
var Bounds = require('./canvas/Bounds');
var Point = require('./canvas/Point');
......@@ -93,7 +94,7 @@ CustomMap.prototype.init = function () {
var mapType = sessionData.getSelectedBackgroundOverlay();
// if we have user data overlays stored in the session then restore it
var ids = sessionData.getVisibleOverlays();
if (mapType !== undefined) {
if (mapType !== undefined && !isNaN(mapType)) {
ids.push(mapType);
}
......@@ -107,7 +108,7 @@ CustomMap.prototype.init = function () {
(x === undefined || y === undefined || zoom === undefined ||
x === null || y === null || zoom === null
)) {
autoFit= true;
autoFit = true;
}
return Promise.all([self.getMapCanvas().triggerListeners('resize'),
......@@ -124,11 +125,13 @@ CustomMap.prototype.init = function () {
self.getMapCanvas().fitBounds(bounds);
}
return Promise.each(ids, function (overlayId) {
return self.openDataOverlay(overlayId).catch(function (e) {
if (e instanceof SecurityError) {
logger.debug(e.message);
if (self.getProject().getDataOverlays().length === 0) {
return Promise.reject(new ValidationError("Project doesn't have a background defined. Please re-upload map in admin panel."));
}
sessionData.setSelectedBackgroundOverlay(self.getProject().getDataOverlays()[0].getId());
} else {
return Promise.reject(e);
......
......@@ -19,6 +19,7 @@ var ReactionMarker = require('../../../main/js/map/marker/ReactionMarker');
var ReactionSurface = require('../../../main/js/map/surface/ReactionSurface');
var ServerConnector = require('./../ServerConnector-mock');
var ValidationError = require('../../../main/js/ValidationError');
var logger = require('./../logger');
......@@ -978,6 +979,18 @@ describe('CustomMap', function () {
})
});
it("project without overlay", function () {
var options = helper.createCustomMapOptions();
options.getProject().removeDataOverlay(options.getProject().getDataOverlays()[0]);
ServerConnector.getSessionData(options.getProject()).setVisibleOverlays([-1]);
var map = new CustomMap(options);
return map.init().then(function () {
assert.fail();
}).catch(function(e){
assert.ok(e instanceof ValidationError);
});
});
it("with session data overlays", function () {
var project = helper.createProject();
var overlay1 = helper.createOverlay();
......
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