diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index bdce56a..876b51d 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit bdce56aff9e458d4d24da9a9a0fca28e100372ad +Subproject commit 876b51d4205c7941862b5455f0763df7a66ffcd1 diff --git a/src/app/topic/indicators.component.ts b/src/app/topic/indicators.component.ts index 7223394..07a1546 100644 --- a/src/app/topic/indicators.component.ts +++ b/src/app/topic/indicators.component.ts @@ -1201,6 +1201,24 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV private checkForSchemaEnhancements(url: string) { this.showCheckForSchemaEnhancements = this.isAdministrator && url && !this.properties.useOldStatisticsSchema && this.indicatorUtils.checkForSchemaEnhancements(url); } + migrateFromOldImportJsonFile(charts){ + // first section contains numbers + // second contains charts + let hasNumbers = false; + for (let chart of charts) { + if (chart['type'] == 'number') { + hasNumbers = true; + break; + } + } + let chartsSection = (hasNumbers?1:0); // no numbers: first sections contains charts + for (let chart of charts) { + if (chart['sectionIndex'] == null) { + chart['sectionIndex'] = chart['type'] == 'chart' ? chartsSection : 0; + } + } + return charts; + } importIndicatorsAndSave(charts: any[]) { let sectionsToSave: Section[] = []; @@ -1208,10 +1226,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV // name description additionalDescription, height, width, visibility let noValidParams = 0; let duplicates = 0; + charts = this.migrateFromOldImportJsonFile(charts); for (let chart of charts) { - if (!chart['sectionIndex']) { - chart['sectionIndex'] = chart['type'] == 'chart' ? 1 : 0; - } if (!sectionsToSave[chart['sectionIndex']]) { let sectionToSave = new Section(chart['sectionType'] ? chart['sectionType'] : chart['type'], chart['sectionTitle']); sectionToSave.indicators = []; @@ -1297,7 +1313,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV this.editing = false; this.importLoading = false; } else if (sectionsToSave.length > 0 && countIndicators > 0) { - sectionsToSave = sectionsToSave.filter(section => !!section); this.saveIndicators(sectionsToSave) } if (sectionsToSave.length == 0 || countIndicators == 0) {