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

zoom level is autoamtiaclly computed if no defaults are provided

parent 2596a140
......@@ -39,6 +39,8 @@ minerva (12.3.0~alpha.0) unstable; urgency=low
about problem with a plugin (#767)
* Small improvement: when exporting reaction and elements there is
possibility to filter by (sub)map (#615)
* Small improvement: during first opening of a map, the zoom level is
automatically computed if no default information is provided
* Bug fix: progress bar of gene genome mapping upload is refreshing properly
(#728)
* Bug fix: when editing project Disease and Organism could not be removed
......
......@@ -94,22 +94,26 @@ CustomMap.prototype.init = function () {
ids.push(mapType);
}
// center map and zoom in to fit into browser window if there is no
// information about coordinates in the session
var x = self.getModel().getDefaultCenterX();
var y = self.getModel().getDefaultCenterY();
var zoom = self.getModel().getDefaultZoomLevel();
var autoFit = false;
if (self.getServerConnector().getSessionData(self.getProject()).getCenter(self.getModel()) === undefined &&
(x === undefined || y === undefined || zoom === undefined ||
x === null || y === null || zoom === null
)) {
autoFit= true;
}
return Promise.all([self.getMapCanvas().triggerListeners('resize'),
// noinspection SpellCheckingInspection
self.getMapCanvas().triggerListeners('maptypeid_changed'),
self.getMapCanvas().triggerListeners('projection_changed')
]).then(function () {
// center map and zoom in to fit into browser window if there is no
// information about coordinates in the session
var x = self.getModel().getDefaultCenterX();
var y = self.getModel().getDefaultCenterY();
var zoom = self.getModel().getDefaultZoomLevel();
if (self.getServerConnector().getSessionData(self.getProject()).getCenter(self.getModel()) === undefined &&
(x === undefined || y === undefined || zoom === undefined ||
x === null || y === null || zoom === null
)) {
if (autoFit) {
var bounds = new Bounds();
bounds.extend(self.getTopLeft());
bounds.extend(self.getBottomRight());
......
......@@ -8,8 +8,8 @@ var chai = require('chai');
var assert = chai.assert;
var logger = require('./logger');
describe('SessionData', function() {
it('setShowComments', function() {
describe('SessionData', function () {
it('setShowComments', function () {
var project = helper.createProject();
var session = new SessionData(project);
session.setShowComments(true);
......@@ -18,22 +18,30 @@ describe('SessionData', function() {
assert.notOk(session.getShowComments());
assert.equal(logger.getWarnings().length, 0);
});
it('setVisibleOverlays', function() {
it('setVisibleOverlays', function () {
var project = helper.createProject();
var session = new SessionData(project);
var overlays = session.getVisibleOverlays();
assert.ok(overlays);
assert.equal(overlays.length, 0);
session.setVisibleOverlays([1,3]);
session.setVisibleOverlays([1, 3]);
overlays = session.getVisibleOverlays();
assert.ok(overlays);
assert.equal(overlays.length, 2);
assert.equal(overlays[0],1);
assert.equal(overlays[1],3);
assert.equal(overlays[0], 1);
assert.equal(overlays[1], 3);
});
it('setCenter for unknown', function () {
var project = helper.createProject();
var session = new SessionData(project);
var point = session.getCenter(project.getModels()[0]);
assert.ok(point === undefined || point === null);
});
});
......@@ -50,7 +50,7 @@ describe('minerva global', function () {
});
});
it('with overview', function () {
helper.setUrl("http://test/?id=complex_model_with_images");
helper.setUrl("http://test/?id=complex_model_with_images&zoom=5");
var customMap;
return ServerConnectorMock.getProject().then(function (project) {
var options = helper.createCustomMapOptions(project);
......@@ -58,6 +58,7 @@ describe('minerva global', function () {
return minerva.create(options);
}).then(function (result) {
customMap = result;
assert.notEqual(5, ServerConnectorMock.getSessionData().getZoomLevel(customMap.getProject().getModels()[0]), "Zoom should be changed because we don't have full info about position")
assert.ok(result);
assert.equal(logger.getWarnings().length, 0);
var showOverviewButton = $(".minerva-overview-button")[0];
......
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