From 3d847f31d153c3af92748815aaab1b0404779235 Mon Sep 17 00:00:00 2001 From: Matthieu Benoist <mbenoist@ausy-group.com> Date: Fri, 24 Jul 2020 15:06:15 +0200 Subject: [PATCH] Fix Initialisation problem when API route is called directly With a direct link to the API tab, the data was not queried, preventing filtering by insee code. --- .../resource-queryable.component.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/dataset-detail/components/dataset-api/resources-queryable/resource-queryable/resource-queryable.component.ts b/src/app/dataset-detail/components/dataset-api/resources-queryable/resource-queryable/resource-queryable.component.ts index 0a57279d..71ac7460 100644 --- a/src/app/dataset-detail/components/dataset-api/resources-queryable/resource-queryable/resource-queryable.component.ts +++ b/src/app/dataset-detail/components/dataset-api/resources-queryable/resource-queryable/resource-queryable.component.ts @@ -152,13 +152,22 @@ export class ResourceQueryableComponent implements OnInit { this.initSettings(); } + initInseeLabel(datasetData) { + const properties = Object.keys(datasetData[0].properties); + this.inseeLabel = properties.find((prop) => { return prop.includes('insee'); }); + } + initURLCustomization() { this.projectionList = []; // 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.initInseeLabel(this._datasetDetailService.datasetData); + } + else { + this._datasetDetailService.retrieveDatasetData().subscribe(()=>{ + this.initInseeLabel(this._datasetDetailService.datasetData); + }); } this.selectedFormat = this.resource.formats[0]; -- GitLab