fix import indicators with no numbers - create separate method to migrate from old json format.
This commit is contained in:
parent
22b22f4afa
commit
c0f76eb601
|
@ -1 +1 @@
|
||||||
Subproject commit bdce56aff9e458d4d24da9a9a0fca28e100372ad
|
Subproject commit 876b51d4205c7941862b5455f0763df7a66ffcd1
|
|
@ -1201,6 +1201,24 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
private checkForSchemaEnhancements(url: string) {
|
private checkForSchemaEnhancements(url: string) {
|
||||||
this.showCheckForSchemaEnhancements = this.isAdministrator && url && !this.properties.useOldStatisticsSchema && this.indicatorUtils.checkForSchemaEnhancements(url);
|
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[]) {
|
importIndicatorsAndSave(charts: any[]) {
|
||||||
let sectionsToSave: Section[] = [];
|
let sectionsToSave: Section[] = [];
|
||||||
|
@ -1208,10 +1226,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
// name description additionalDescription, height, width, visibility
|
// name description additionalDescription, height, width, visibility
|
||||||
let noValidParams = 0;
|
let noValidParams = 0;
|
||||||
let duplicates = 0;
|
let duplicates = 0;
|
||||||
|
charts = this.migrateFromOldImportJsonFile(charts);
|
||||||
for (let chart of charts) {
|
for (let chart of charts) {
|
||||||
if (!chart['sectionIndex']) {
|
|
||||||
chart['sectionIndex'] = chart['type'] == 'chart' ? 1 : 0;
|
|
||||||
}
|
|
||||||
if (!sectionsToSave[chart['sectionIndex']]) {
|
if (!sectionsToSave[chart['sectionIndex']]) {
|
||||||
let sectionToSave = new Section(chart['sectionType'] ? chart['sectionType'] : chart['type'], chart['sectionTitle']);
|
let sectionToSave = new Section(chart['sectionType'] ? chart['sectionType'] : chart['type'], chart['sectionTitle']);
|
||||||
sectionToSave.indicators = [];
|
sectionToSave.indicators = [];
|
||||||
|
@ -1297,7 +1313,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
this.importLoading = false;
|
this.importLoading = false;
|
||||||
} else if (sectionsToSave.length > 0 && countIndicators > 0) {
|
} else if (sectionsToSave.length > 0 && countIndicators > 0) {
|
||||||
sectionsToSave = sectionsToSave.filter(section => !!section);
|
|
||||||
this.saveIndicators(sectionsToSave)
|
this.saveIndicators(sectionsToSave)
|
||||||
}
|
}
|
||||||
if (sectionsToSave.length == 0 || countIndicators == 0) {
|
if (sectionsToSave.length == 0 || countIndicators == 0) {
|
||||||
|
|
Loading…
Reference in New Issue