Skip to content
Snippets Groups Projects
Commit 52e59812 authored by ext.sopra.ncastejon's avatar ext.sopra.ncastejon
Browse files

Display the correct formats in the Download tab.

parent ba3a1b64
No related branches found
No related tags found
No related merge requests found
......@@ -105,15 +105,43 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
return formatted;
}
// Get the formats available to download
get datasetFormatsList() {
const links = this._datasetDetailService.datasetMetadata.link;
let list = links.map(l => l.formats);
let list = links.map((link) => {
let filteredList = link.formats;
if (link.formats) {
filteredList = link.formats.filter((f) => {
let validFormat = true;
if (!f) {
validFormat = false;
}
// If nongeographical dataset, there is no shapefile format
// tslint:disable-next-line: ter-indent
// tslint:disable-next-line: brace-style
else if (this._datasetDetailService.datasetMetadata.type === 'nonGeographicDataset'
&& f === 'ShapeFile') {
validFormat = false;
} else if (f === 'PDF' && link.name.includes('Licence')) { // Remove PDF because it's Licence
validFormat = false;
}
return validFormat;
});
}
return filteredList;
});
// Flat the arrays
list = [].concat(...list);
// Remove duplicates
list = [...new Set(list)];
list = list.filter((el) => {
return el !== undefined;
});
let formatted: string;
if (list.length > 4) {
......@@ -122,10 +150,6 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
formatted = list.join(', ');
}
if (links.length === 1 && links[0].name.includes('Licence')) {
formatted = null;
}
return formatted;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment