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

Merge branch '997-refresh-button' into 'devel_14.0.x'

refresh button did not refresh overlay list after overlay was removed over API

See merge request minerva/core!1004
parents 01e27909 bcc10b2b
......@@ -7,6 +7,8 @@ minerva (14.0.3) stable; urgency=high
crashed visualization (#966)
* Bug fix: list of overlays for admin and curator included also other people
overlays (regression 14.0.3, #1008)
* Bug fix: refresh button did not refresh overlay list after overlay was
removed over API (#997)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 07 Nov 2019 16:00:00 +0200
......
......@@ -457,6 +457,7 @@ OverlayPanel.prototype.refresh = function (showDefault) {
var overlayTypes = [];
var selectedOverlay = [];
var overlaysFromServer = [];
return self.getServerConnector().getOverlayTypes().then(function (types) {
overlayTypes = types;
......@@ -470,9 +471,27 @@ OverlayPanel.prototype.refresh = function (showDefault) {
}
return self.getServerConnector().getOverlays({creator: user.getLogin()});
}).then(function (overlaysFromServer) {
}).then(function (userOverlays) {
overlaysFromServer = userOverlays;
return self.getServerConnector().getOverlays({publicOverlay: true});
}).then(function (publicOverlays) {
overlaysFromServer = overlaysFromServer.concat((publicOverlays));
self.getProject().addOrUpdateDataOverlays(overlaysFromServer);
var overlays = self.getProject().getDataOverlays();
for (var index = 0; index < overlays.length; index++) {
var remove = true;
for (var index2 = 0; index2 < overlaysFromServer.length; index2++) {
if (overlaysFromServer[index2].getId() === overlays[index].getId()) {
remove = false;
}
}
if (remove) {
self.getProject().removeDataOverlay(overlays[index]);
}
}
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."));
......@@ -486,7 +505,7 @@ OverlayPanel.prototype.refresh = function (showDefault) {
var generalOverlays = [];
var overlay;
var overlays = self.getProject().getDataOverlays();
overlays = self.getProject().getDataOverlays();
var customOverlays = [];
var defaultOverlay = null;
for (var i = 0; i < overlays.length; i++) {
......
......@@ -38,36 +38,43 @@ describe('OverlayPanel', function () {
describe('refresh', function () {
it('anonymous', function () {
var map = helper.createCustomMap();
map.getProject().addDataOverlay(helper.createBackgroundOverlay());
var panel;
return ServerConnector.getProject("sample").then(function (project) {
project.addDataOverlay(helper.createBackgroundOverlay());
var map = helper.createCustomMap(project);
var panel = new OverlayPanel({
element: testDiv,
customMap: map
});
return panel.init().then(function () {
panel = new OverlayPanel({
element: testDiv,
customMap: map
});
return panel.init();
}).then(function () {
return panel.refresh();
}).then(function () {
assert.ok(panel.getElement().innerHTML.indexOf("testLayout") >= 0);
assert.ok(panel.getElement().innerHTML.indexOf("testLayout") < 0);
assert.ok(panel.getElement().innerHTML.indexOf("YOU ARE NOT LOGGED") >= 0);
return panel.destroy();
});
});
it('admin', function () {
helper.loginAsAdmin();
var map = helper.createCustomMap();
map.getProject().addDataOverlay(helper.createBackgroundOverlay());
var panel;
return ServerConnector.getProject("sample").then(function (project) {
project.addDataOverlay(helper.createBackgroundOverlay());
var map = helper.createCustomMap(project);
var panel = new OverlayPanel({
element: testDiv,
customMap: map
});
panel = new OverlayPanel({
element: testDiv,
customMap: map
});
return panel.init().then(function () {
return panel.init();
}).then(function () {
return panel.refresh();
}).then(function () {
assert.ok(panel.getElement().innerHTML.indexOf("testLayout") >= 0);
assert.ok(panel.getElement().innerHTML.indexOf("testLayout") < 0);
assert.ok(panel.getElement().innerHTML.indexOf("YOU ARE NOT LOGGED") < 0);
return panel.destroy();
});
});
......@@ -119,16 +126,17 @@ describe('OverlayPanel', function () {
});
});
it('download', function () {
var map = helper.createCustomMap();
map.getProject().addDataOverlay(helper.createBackgroundOverlay());
var panel;
return ServerConnector.getProject("sample").then(function (project) {
var map = helper.createCustomMap(project);
var panel = new OverlayPanel({
element: testDiv,
customMap: map
});
panel = new OverlayPanel({
element: testDiv,
customMap: map
});
return panel.init().then(function () {
return panel.init();
}).then(function () {
return panel.refresh();
}).then(function () {
var buttons = panel.getElement().getElementsByTagName("button");
......
......@@ -371,6 +371,7 @@ describe('minerva global', function () {
var submapId = 16729;
var submapParameter;
var projectId = "complex_model_with_submaps";
helper.setUrl("http://test/?id=complex_model_with_submaps");
return ServerConnectorMock.getProject(projectId).then(function (project) {
var options = helper.createCustomMapOptions(project);
options.setDebug(true);
......
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