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

opening info window fixed

parent 1972cf79
......@@ -679,18 +679,26 @@ AbstractCustomMap.prototype._openInfoWindowForAlias = function(aliasId, onready)
* {@link Alias} in all currently visualized layouts
*/
AbstractCustomMap.prototype.getAliasVisibleLayoutsData = function(aliasId) {
var layouts = this.getTopMap().getSelectedLayouts();
var result = [];
for (var i = 0; i < layouts.length; i++) {
var layout = this.getModel().getLayoutDataById(layouts[i]);
if (layout !== null && layout !== undefined) {
result.push(layout.aliasById[aliasId]);
} else {
logger.warn("No layout data found for layout: " + layouts[i]);
result.push(null);
}
var layoutIds = this.getTopMap().getSelectedLayouts();
var promises = [];
for (var i = 0; i < layoutIds.length; i++) {
promises.push(this.getModel().getLayoutDataById(layoutIds[i]));
}
return result;
return new Promise(function(resolve){
return Promise.all(promises).then(function(layouts){
var result = [];
for (var i = 0; i < layouts.length; i++) {
var layout = layouts[i];
if (layout !== null && layout !== undefined) {
result.push(layout.aliasById[aliasId]);
} else {
logger.warn("No layout data found for layout: " + layouts[i]);
result.push(null);
}
}
resolve(result);
});
});
};
/**
......
......@@ -146,18 +146,28 @@ AliasInfoWindow.prototype.createContentDiv = function() {
title.innerHTML = this.alias.type + ": " + this.alias.name;
result.appendChild(title);
this.layoutAliases = this.customMap.getAliasVisibleLayoutsData(this.alias.getId());
this.layoutNames = this.customMap.getVisibleLayoutNames();
var self = this;
var layoutsDiv = document.createElement("div");
result.appendChild(layoutsDiv);
self.getCustomMap().getAliasVisibleLayoutsData(this.alias.getId()).then(function(layoutAliases){
self.layoutAliases = layoutAliases;
return self.getCustomMap().getVisibleLayoutNames();
}).then(function(layoutNames){
self.layoutNames = layoutNames;
var chartDiv = self.createChartDiv();
if (chartDiv !== null) {
layoutsDiv.appendChild(chartDiv);
}
var genomicDiv = self.createGenomicDiv();
if (genomicDiv !== null) {
layoutsDiv.appendChild(genomicDiv);
}
});
var chartDiv = this.createChartDiv();
if (chartDiv !== null) {
result.appendChild(chartDiv);
}
var genomicDiv = this.createGenomicDiv();
if (genomicDiv !== null) {
result.appendChild(genomicDiv);
}
return result;
} else {
......
......@@ -559,4 +559,22 @@ describe('CustomMap', function() {
assert.ok(ServerConnector.getExportModelId());
});
it("getAliasVisibleLayoutsData", function() {
var mockObject = helper.createCustomMap();
var alias = helper.createAlias();
mockObject.getModel().addAlias(alias);
var layout = helper.createLayout();
layout.setInitialized(true);
mockObject.getModel().addLayout(layout);
return mockObject.addSelectedLayout(layout.getId()).then(function() {
return mockObject.getAliasVisibleLayoutsData(alias.getId());
}).then(function(layoutAliases) {
assert.equal(layoutAliases.length, 1);
});
});
});
......@@ -70,17 +70,20 @@ describe('AliasInfoWindow', function() {
// create a mock function that will return list of layouts alias
// data
map.getAliasVisibleLayoutsData = function() {
var result = [];
result.push(new LayoutAlias({
idObject : "1",
color : {
falpha : 0,
value : -8388737
}
}));
result.push(null);
return result;
return new Promise(function(resolve) {
var result = [];
result.push(new LayoutAlias({
idObject : "1",
color : {
falpha : 0,
value : -8388737
}
}));
result.push(null);
resolve(result);
});
};
map.getVisibleLayoutNames = function() {
return [ "name 1", "name 2" ];
};
......@@ -117,16 +120,18 @@ describe('AliasInfoWindow', function() {
// create a mock function that will return list of layouts alias
// data
map.getAliasVisibleLayoutsData = function() {
var result = [];
result.push(new LayoutAlias({
idObject : "1",
color : {
falpha : 0,
value : -8388737
}
}));
result.push(null);
return result;
return new Promise(function(resolve) {
var result = [];
result.push(new LayoutAlias({
idObject : "1",
color : {
falpha : 0,
value : -8388737
}
}));
result.push(null);
resolve(result);
});
};
map.getVisibleLayoutNames = function() {
return [ "name 1", "name 2" ];
......@@ -146,7 +151,6 @@ describe('AliasInfoWindow', function() {
aliasWindow.update();
assert.ok(aliasWindow.getContent().innerHTML.indexOf("loading") === -1);
assert.ok(aliasWindow.getContent().innerHTML.indexOf("name 1") > -1);
});
it("AliasInfoWindow createOverlayInfoDiv", function() {
......
This diff is collapsed.
Supports Markdown
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