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

Display the correct formats in the Download tab.

parent 0a962f90
No related branches found
No related tags found
1 merge request!62v2.5.0
......@@ -109,15 +109,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) {
......@@ -126,10 +154,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