Commit 5173181f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '973-minervanet-error-report-116' into 'master'

Resolve "MINERVANET - Error Report 116"

Closes #973

See merge request minerva/core!964
parents e701559a 1f80cb72
Pipeline #15152 passed with stage
in 10 minutes and 26 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');
......@@ -957,25 +958,26 @@ describe('CustomMap', function () {
});
describe("init", function () {
it("invalid background overlay", function () {
it("non-existing background overlay", function () {
var options = helper.createCustomMapOptions();
ServerConnector.getSessionData(options.getProject()).setSelectedBackgroundOverlay("bla");
ServerConnector.getSessionData(options.getProject()).setSelectedBackgroundOverlay(-1);
var map = new CustomMap(options);
return map.init().then(function () {
assert.false("Error expected");
}, function () {
map.destroy();
assert.ok(ServerConnector.getSessionData(options.getProject()).getSelectedBackgroundOverlay() > 0);
return map.destroy();
})
});
it("non-existing background overlay", function () {
it("project without overlay", function () {
var options = helper.createCustomMapOptions();
ServerConnector.getSessionData(options.getProject()).setSelectedBackgroundOverlay(-1);
options.getProject().removeDataOverlay(options.getProject().getDataOverlays()[0]);
ServerConnector.getSessionData(options.getProject()).setVisibleOverlays([-1]);
var map = new CustomMap(options);
return map.init().then(function () {
assert.ok(ServerConnector.getSessionData(options.getProject()).getSelectedBackgroundOverlay() > 0);
return map.destroy();
})
assert.fail();
}).catch(function(e){
assert.ok(e instanceof ValidationError);
});
});
it("with session data overlays", function () {
......
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