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

getVisibleLayoutNames refactored to remove function from loop

parent e1ba1e3a
......@@ -697,27 +697,18 @@ AbstractCustomMap.prototype.getVisibleLayoutNames = function() {
var layouts = this.getTopMap().getSelectedLayouts();
return new Promise(function(resolve) {
var result = [];
var layoutsProcessed = 0;
var layoutCount = layouts.length;
var onProcessedFun = function() {
if (layoutCount === layoutsProcessed) {
resolve(result);
}
};
for (var i = 0; i < layoutCount; i++) {
self.getModel().getLayoutDataById(layouts[i]).then(function(layout) {
return Promise.each(layouts, function(item, index) {
return self.getModel().getLayoutDataById(item).then(function(layout) {
if (layout !== null && layout !== undefined) {
result.push(layout.name);
result[index] = layout.name;
} else {
logger.warn("No layout data found for layout: " + layouts[i]);
result.push(null);
logger.warn("No layout data found for layout: " + layouts[index]);
result[index] = null;
}
layoutsProcessed++;
onProcessedFun();
});
}
onProcessedFun();
}).then(function(){
resolve(result);
});
});
};
......
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