From 0a962f90172e1b23665bf2b4cef26e3779430daa Mon Sep 17 00:00:00 2001 From: "ext.sopra.ncastejon" <castejon.nicolas@gmail.com> Date: Thu, 19 Mar 2020 15:01:08 +0100 Subject: [PATCH] Fix the download items for non geographical datasets. --- .../dataset-detail.component.html | 2 +- .../dataset-detail.component.ts | 7 ++- .../dataset-downloads.component.html | 13 +++-- .../resource-download-item.component.html | 16 ++--- .../resource-download-item.component.scss | 3 + .../resource-download-item.component.ts | 58 ++++++++++--------- .../services/resources.service.ts | 1 + 7 files changed, 59 insertions(+), 41 deletions(-) diff --git a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html index 05a0bf80..ec361916 100644 --- a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html +++ b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html @@ -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" diff --git a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts index ea8cc7d9..8602c83d 100644 --- a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts +++ b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts @@ -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; } diff --git a/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.html b/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.html index 173a6c1e..4e132e8f 100644 --- a/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.html +++ b/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.html @@ -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> diff --git a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.html b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.html index 331a5a46..0e2575e1 100644 --- a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.html +++ b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.html @@ -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> - </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> diff --git a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.scss b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.scss index c8f6f539..aea974c8 100644 --- a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.scss +++ b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.scss @@ -62,6 +62,9 @@ display: flex; } +.dropdown-item { + overflow: hidden; +} .dropdown-insee { .dropdown-menu { diff --git a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts index 99e64d66..feb199d0 100644 --- a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts +++ b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts @@ -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() { diff --git a/src/app/dataset-detail/services/resources.service.ts b/src/app/dataset-detail/services/resources.service.ts index f494a77b..0da5c354 100644 --- a/src/app/dataset-detail/services/resources.service.ts +++ b/src/app/dataset-detail/services/resources.service.ts @@ -54,6 +54,7 @@ export class ResourcesService { const downloadableResources = []; const staticResources = []; const otherResources = []; + console.log(metadata.link); metadata.link.forEach((link) => { if (link.service) { -- GitLab