Commit 13644fb5 authored by ext.sopra.ncastejon's avatar ext.sopra.ncastejon
Browse files

Display the correct formats in the Download tab.

parent 0a962f90
...@@ -109,15 +109,43 @@ export class DatasetDetailComponent implements OnInit, OnDestroy { ...@@ -109,15 +109,43 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
return formatted; return formatted;
} }
// Get the formats available to download
get datasetFormatsList() { get datasetFormatsList() {
const links = this._datasetDetailService.datasetMetadata.link; 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 // Flat the arrays
list = [].concat(...list); list = [].concat(...list);
// Remove duplicates // Remove duplicates
list = [...new Set(list)]; list = [...new Set(list)];
list = list.filter((el) => {
return el !== undefined;
});
let formatted: string; let formatted: string;
if (list.length > 4) { if (list.length > 4) {
...@@ -126,10 +154,6 @@ export class DatasetDetailComponent implements OnInit, OnDestroy { ...@@ -126,10 +154,6 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
formatted = list.join(', '); formatted = list.join(', ');
} }
if (links.length === 1 && links[0].name.includes('Licence')) {
formatted = null;
}
return formatted; return formatted;
} }
......
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