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

refresh of list of overlays refresh also overlays in the publi data overlays

parent 2226f911
......@@ -468,12 +468,9 @@ OverlayPanel.prototype.refresh = function (showDefault) {
selectedOverlay[visibleDataOverlays[j].getId()] = true;
}
return self.getServerConnector().getOverlays({
publicOverlay: false,
creator: user.getLogin()
});
}).then(function (customOverlays) {
self.getProject().addOrUpdateDataOverlays(customOverlays);
return self.getServerConnector().getOverlays();
}).then(function (overlaysFromServer) {
self.getProject().addOrUpdateDataOverlays(overlaysFromServer);
if (!showDefault) {
var id = self.getMap().getBackgroundDataOverlay().getId();
......@@ -486,15 +483,22 @@ OverlayPanel.prototype.refresh = function (showDefault) {
var overlay;
var overlays = self.getProject().getDataOverlays();
var customOverlays = [];
var defaultOverlay = null;
for (var i = 0; i < overlays.length; i++) {
overlay = overlays[i];
if (overlay.getCreator() === undefined || overlay.getCreator() === "") {
generalOverlays.push(overlay);
if (showDefault && overlay.isDefaultOverlay()) {
selectedOverlay[overlay.getId()] = true;
defaultOverlay = overlay;
}
} else {
customOverlays.push(overlay);
}
}
if (defaultOverlay !== null) {
selectedOverlay[defaultOverlay.getId()] = true;
}
var table = self.getControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE);
table.appendChild(self.createTableHeader());
......@@ -578,6 +582,8 @@ OverlayPanel.prototype.refresh = function (showDefault) {
}
}
return Promise.all(promises);
}).then(function () {
return self.getMap().redrawSelectedDataOverlays();
});
};
......
......@@ -414,6 +414,9 @@ DataOverlay.prototype.isGoogleLicenseConsent = function () {
* @param {DataOverlay} overlay
*/
DataOverlay.prototype.update = function (overlay) {
this.setPublicOverlay(overlay.getPublicOverlay());
this.setOrder(overlay.getOrder());
this.setCreator(overlay.getCreator());
this.setName(overlay.getName());
this.setDescription(overlay.getDescription());
};
......
......@@ -32,6 +32,10 @@ function Project(data) {
ObjectWithListeners.call(this);
this.registerListenerType("onreload");
/**
* @type {Array<DataOverlay>}
* @private
*/
this._dataOverlays = [];
this._models = [];
this._elementsPointingToSubmap = [];
......
......@@ -39,6 +39,7 @@ describe('OverlayPanel', function () {
describe('refresh', function () {
it('anonymous', function () {
var map = helper.createCustomMap();
map.getProject().addDataOverlay(helper.createBackgroundOverlay());
var panel = new OverlayPanel({
element: testDiv,
......@@ -55,6 +56,7 @@ describe('OverlayPanel', function () {
it('admin', function () {
helper.loginAsAdmin();
var map = helper.createCustomMap();
map.getProject().addDataOverlay(helper.createBackgroundOverlay());
var panel = new OverlayPanel({
element: testDiv,
......@@ -119,9 +121,7 @@ describe('OverlayPanel', function () {
it('download', function () {
var map = helper.createCustomMap();
var overlay = helper.createOverlay();
overlay.setInputDataAvailable(true);
map.getProject().addDataOverlay(overlay);
map.getProject().addDataOverlay(helper.createBackgroundOverlay());
var panel = new OverlayPanel({
element: testDiv,
......
......@@ -434,6 +434,19 @@ Helper.prototype.createOverlay = function (model) {
});
};
/**
*
* @param {MapModel} [model]
* @returns {DataOverlay}
*/
Helper.prototype.createBackgroundOverlay = function (model) {
var result = this.createOverlay(model);
result.setInputDataAvailable(true);
result.setDefaultOverlay(true);
result.setName("empty");
return result;
};
/**
*
* @param {Project} [project]
......
[{"defaultOverlay":false,"deprecatedColumns":[],"description":null,"googleLicenseConsent":false,"idObject":17987,"images":[{"modelId":19397,"path":"_nested0"},{"modelId":19399,"path":"_nested3"},{"modelId":19398,"path":"_nested1"},{"modelId":19400,"path":"_nested2"}],"inputDataAvailable":false,"name":"Pathways and compartments","order":1,"publicOverlay":true},{"defaultOverlay":false,"deprecatedColumns":[],"description":null,"googleLicenseConsent":false,"idObject":17988,"images":[{"modelId":19397,"path":"_normal0"},{"modelId":19399,"path":"_normal3"},{"modelId":19398,"path":"_normal1"},{"modelId":19400,"path":"_normal2"}],"inputDataAvailable":false,"name":"Network","order":1,"publicOverlay":true},{"defaultOverlay":false,"deprecatedColumns":[],"description":null,"googleLicenseConsent":false,"idObject":17989,"images":[{"modelId":19397,"path":"_empty0"},{"modelId":19399,"path":"_empty3"},{"modelId":19398,"path":"_empty1"},{"modelId":19400,"path":"_empty2"}],"inputDataAvailable":false,"name":"Empty","order":1,"publicOverlay":true}]
\ No newline at end of file
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