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

tabs in add project are available when data is ready to upload

parent fdfbd0ac
Pipeline #4271 passed with stage
in 1 minute and 6 seconds
......@@ -101,13 +101,27 @@ AddProjectDialog.prototype.addTab = function (params) {
});
contentDiv.style.overflow = "auto";
if (params.content !== undefined) {
contentDiv.appendChild(params.content);
}
params.tabContentDiv.appendChild(contentDiv);
if (params.disabled) {
this.disableTab(params);
}
};
AddProjectDialog.prototype.disableTab = function (params) {
$("a[href='#" + params.id + "']", this.getElement()).hide();
};
AddProjectDialog.prototype.enableTab = function (params) {
$("a[href='#" + params.id + "']", this.getElement()).show();
};
AddProjectDialog.prototype.showAnnotatorsDialog = function () {
var self = this;
var promise;
......@@ -319,7 +333,8 @@ AddProjectDialog.prototype.createOverlaysTab = function (tabMenuDiv, tabContentD
tabContentDiv: tabContentDiv,
name: "OVERLAYS",
id: "project_overlays_tab",
content: self.createOverlaysTabContent()
content: self.createOverlaysTabContent(),
disabled: true
});
};
......@@ -396,7 +411,8 @@ AddProjectDialog.prototype.createSubmapsTab = function (tabMenuDiv, tabContentDi
tabContentDiv: tabContentDiv,
name: "SUBMAPS",
id: "project_submaps_tab",
content: self.createSubmapsTabContent()
content: self.createSubmapsTabContent(),
disabled: true
});
};
......@@ -540,7 +556,8 @@ AddProjectDialog.prototype.createOverviewImagesTab = function (tabMenuDiv, tabCo
tabContentDiv: tabContentDiv,
name: "IMAGES",
id: "project_overview_images_tab",
content: self.createOverviewImagesTabContent()
content: self.createOverviewImagesTabContent(),
disabled: true
});
};
......@@ -890,22 +907,53 @@ AddProjectDialog.prototype.setZipFileContent = function (file) {
return jsZip.loadAsync(file).then(function (zip) {
var files = zip.files;
var promises = [];
var entries = [];
for (var key in files) {
if (files.hasOwnProperty(key)) {
promises.push(self.createZipEntry(files[key], zip));
}
}
return Promise.all(promises).then(function (result) {
for (var i = 0; i < result.length; i++) {
if (result[i] !== null) {
entries.push(result[i]);
return Promise.all(promises);
}).then(function (result) {
var entries = [];
var overlays = 0;
var maps = 0;
var images = 0;
for (var i = 0; i < result.length; i++) {
var entry = result[i];
if (entry !== null) {
entries.push(entry);
if (entry.getType() === 'MAP') {
maps++;
} else if (entry.getType() === 'IMAGE') {
images++;
} else if (entry.getType() === 'OVERLAY') {
overlays++;
}
}
return self.setZipEntries(entries);
});
}
if (overlays > 0) {
self.enableTab({id: "project_overlays_tab"});
} else {
self.disableTab({id: "project_overlays_tab"});
}
if (maps > 1) {
self.enableTab({id: "project_submaps_tab"});
} else {
self.disableTab({id: "project_submaps_tab"});
}
if (images > 1) {
self.enableTab({id: "project_overview_images_tab"});
} else {
self.disableTab({id: "project_overview_images_tab"});
}
return self.setZipEntries(entries);
});
} else {
self.disableTab({id: "project_overlays_tab"});
self.disableTab({id: "project_submaps_tab"});
self.disableTab({id: "project_overview_images_tab"});
return self.setZipEntries([]);
}
};
......
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