Commit 0a962f90 authored by ext.sopra.ncastejon's avatar ext.sopra.ncastejon
Browse files

Fix the download items for non geographical datasets.

parent 570beda7
......@@ -46,7 +46,7 @@
</div>
</a>
</li>
<li [routerLinkActive]="'is-active'">
<li [routerLinkActive]="'is-active'" *ngIf="datasetFormatsList">
<a (click)="setPosition()" [routerLink]="[AppRoutes.downloads.uri]" class="tab-link">
<svg class="tab-icon" xmlns="http://www.w3.org/2000/svg" data-name="Calque 1" viewBox="0 0 38 32">
<path class="primary"
......
......@@ -111,7 +111,8 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
get datasetFormatsList() {
let list = this._datasetDetailService.datasetMetadata.link.map(l => l.formats);
const links = this._datasetDetailService.datasetMetadata.link;
let list = links.map(l => l.formats);
// Flat the arrays
list = [].concat(...list);
// Remove duplicates
......@@ -125,6 +126,10 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
formatted = list.join(', ');
}
if (links.length === 1 && links[0].name.includes('Licence')) {
formatted = null;
}
return formatted;
}
......
......@@ -8,10 +8,11 @@
<span>{{downloadable.key}}</span>
</div>
<div class="resource-downloadable-files" *ngFor="let resource of downloadable.value">
<ng-container *ngFor="let format of resource.formats; let i=index">
<app-resource-download-item [format]="format" [resource]="resource" [projections]="projections" [isQueryable]="true">
</app-resource-download-item>
</ng-container>
<ng-container *ngFor="let format of resource.formats; let i=index">
<app-resource-download-item [format]="format" [resource]="resource" [projections]="projections"
[isQueryable]="true">
</app-resource-download-item>
</ng-container>
</div>
</div>
</div>
......@@ -22,8 +23,8 @@
<span>{{static.key}}</span>
</div>
<div class="resource-static-files" *ngFor="let metadataLink of static.value">
<app-resource-download-item [link]="metadataLink" [isQueryable]="false">
</app-resource-download-item>
<app-resource-download-item [link]="metadataLink" [isQueryable]="false">
</app-resource-download-item>
</div>
</div>
</div>
......
......@@ -9,7 +9,7 @@
<span>{{isQueryable ? resource.metadataLink.name + '.' + format.fileExtension : link.name }}
</span>
</div>
<div class="resource-options">
<div class="resource-options is-hidden-mobile" *ngIf="format && format.isCuttable">
<div>
<span *ngIf="this.selectedProjection"> {{this.selectedProjection.name}}
</span>
......@@ -22,7 +22,7 @@
<div *ngIf="! this.selectedInsee && format.isCuttable">
<span>&nbsp;-&nbsp;</span>
<span i18n="@@dataset.resources.divisionbycommune">
<span i18n="@@dataset.resources.allcommune">
All the municipalities
</span>
</div>
......@@ -31,7 +31,7 @@
</div>
<div class="right-buttons">
<div *ngIf="(format.isCuttable && inseeLabel) || format.isProjectable"
<div *ngIf="format && ((format.isCuttable && inseeLabel) || format.isProjectable)"
class="options-icon is-hidden-mobile" [ngClass]="{'is-open': isOptionOpen}"
(click)="isOptionOpen = !isOptionOpen">
......@@ -64,7 +64,7 @@
</div>
<div class="filter-items is-hidden-mobile" *ngIf="isOptionOpen">
<div class="filter-items is-hidden-mobile" *ngIf="isQueryable && isOptionOpen">
<div class="division-item" *ngIf="format.isCuttable && inseeLabel">
<div class="label-dropdown title-label">
......@@ -93,8 +93,9 @@
</div>
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content">
<a class="dropdown-item" (click)="setInsee(null)" i18n="@@global.all.feminine">All</a>
<a class="dropdown-item" *ngFor="let zone of communeInseeList" (click)="setInsee(zone)">
<a class="dropdown-item" (click)="setInsee(null)" i18n="@@global.all.commune">All</a>
<a class="dropdown-item" [title]="zone.commune + ' ' + zone.insee"
*ngFor="let zone of communeInseeList" (click)="setInsee(zone)">
{{ zone.commune }} - {{ zone.insee }}
</a>
</div>
......@@ -129,7 +130,8 @@
</div>
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content">
<a class="dropdown-item" *ngFor="let projection of projectionList" (click)="setProjection(projection)">
<a class="dropdown-item" [title]="getProjectionLabel(projection.name)"
*ngFor="let projection of projectionList" (click)="setProjection(projection)">
{{ getProjectionLabel(projection.name) }}
</a>
</div>
......
......@@ -62,6 +62,9 @@
display: flex;
}
.dropdown-item {
overflow: hidden;
}
.dropdown-insee {
.dropdown-menu {
......
......@@ -15,8 +15,8 @@ export class ResourceDownloadItemComponent implements OnInit {
linkFormats = linkFormats;
@Input() format?: Format;
@Input() resource: Resource;
@Input() projections: Projection[];
@Input() resource?: Resource;
@Input() projections?: Projection[];
@Input() link: IMetadataLink;
@Input() isQueryable: boolean;
@Output() saveEvent = new EventEmitter();
......@@ -87,6 +87,8 @@ export class ResourceDownloadItemComponent implements OnInit {
ngOnInit() {
console.log(this.resource);
console.log(this.format);
this.initItems();
// Retrieve the first data for the dataset (if exists). It will be used in the
// Data, Downloads and API tabs.
......@@ -97,34 +99,38 @@ export class ResourceDownloadItemComponent implements OnInit {
initItems() {
// Get projections and set the default one (depending on the resource)
this.projectionList = [];
if (this.resource.type === linkFormats.wms) {
this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection);
this.selectedProjection = this.projectionList[0];
} else if (this.resource.type === linkFormats.wfs) {
this.resource.metadataLink.projections.forEach((key) => {
this.projectionList.push({
name: key,
bbox: key,
if (this.resource) {
this.projectionList = [];
if (this.resource.type === linkFormats.wms) {
this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection);
this.selectedProjection = this.projectionList[0];
} else if (this.resource.type === linkFormats.wfs) {
this.resource.metadataLink.projections.forEach((key) => {
this.projectionList.push({
name: key,
bbox: key,
});
});
});
this.selectedProjection = this.projectionList[0];
} else if (this.resource.type === linkFormats.wcs) {
this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection);
this.selectedProjection = this.projectionList[0];
} else if (this.resource.type === linkFormats.ws) {
this.projectionList = this.transformObjectToArray(this.shpProjections);
this.selectedProjection = this.projectionList[0];
}
this.selectedProjection = this.projectionList[0];
} else if (this.resource.type === linkFormats.wcs) {
this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection);
this.selectedProjection = this.projectionList[0];
} else if (this.resource.type === linkFormats.ws) {
this.projectionList = this.transformObjectToArray(this.shpProjections);
this.selectedProjection = this.projectionList[0];
}
// Set the insee property label for this dataset
if (this._datasetDetailService.datasetData[0]) {
const properties = Object.keys(this._datasetDetailService.datasetData[0].properties);
this.inseeLabel = properties.find((prop) => { return prop.includes('insee'); });
}
this.communeInseeList.sort((a, b) => (a.commune > b.commune) ? 1 : -1);
// Set the insee property label for this dataset
if (this._datasetDetailService.datasetData[0]) {
const properties = Object.keys(this._datasetDetailService.datasetData[0].properties);
this.inseeLabel = properties.find((prop) => { return prop.includes('insee'); });
this.setProjection(this.selectedProjection);
}
this.communeInseeList.sort((a, b) => (a.commune > b.commune) ? 1 : -1);
this.setProjection(this.selectedProjection);
}
getFormatName() {
......
......@@ -54,6 +54,7 @@ export class ResourcesService {
const downloadableResources = [];
const staticResources = [];
const otherResources = [];
console.log(metadata.link);
metadata.link.forEach((link) => {
if (link.service) {
......
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