From f93b1ef82c34c1b150f1c0b64f1e9ed18b9ac7b5 Mon Sep 17 00:00:00 2001 From: Stepan Kiryakov Date: Wed, 9 Oct 2024 15:54:49 +0400 Subject: [PATCH] fix Signed-off-by: Stepan Kiryakov --- .../models/schema-formulas.ts | 2 +- ...ic-assessment-configuration.component.html | 12 +++--- ...stic-assessment-configuration.component.ts | 38 +++++++++++-------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/frontend/src/app/modules/policy-statistics/models/schema-formulas.ts b/frontend/src/app/modules/policy-statistics/models/schema-formulas.ts index 24869077a..ab4504d56 100644 --- a/frontend/src/app/modules/policy-statistics/models/schema-formulas.ts +++ b/frontend/src/app/modules/policy-statistics/models/schema-formulas.ts @@ -95,6 +95,6 @@ export class SchemaFormulas { } public getJson(): any[] { - return this.formulas.map((f) => f.getJson()); + return this.formulas.filter((f) => f.description || f.formula).map((f) => f.getJson()); } } \ No newline at end of file diff --git a/frontend/src/app/modules/policy-statistics/statistic-assessment-configuration/statistic-assessment-configuration.component.html b/frontend/src/app/modules/policy-statistics/statistic-assessment-configuration/statistic-assessment-configuration.component.html index 6d6e2b4b5..cbcda80ed 100644 --- a/frontend/src/app/modules/policy-statistics/statistic-assessment-configuration/statistic-assessment-configuration.component.html +++ b/frontend/src/app/modules/policy-statistics/statistic-assessment-configuration/statistic-assessment-configuration.component.html @@ -240,13 +240,13 @@
- {{v}} + {{getVariableValue(v)}}
- {{variable.value}} + {{getVariableValue(variable.value)}}
@@ -266,13 +266,13 @@
- {{v}} + {{getVariableValue(v)}}
- {{variable.value}} + {{getVariableValue(variable.value)}}
@@ -313,13 +313,13 @@
- {{v}} + {{getVariableValue(v)}}
- {{variable.value}} + {{getVariableValue(variable.value)}}
diff --git a/frontend/src/app/modules/policy-statistics/statistic-assessment-configuration/statistic-assessment-configuration.component.ts b/frontend/src/app/modules/policy-statistics/statistic-assessment-configuration/statistic-assessment-configuration.component.ts index d2df33693..c90ab28cd 100644 --- a/frontend/src/app/modules/policy-statistics/statistic-assessment-configuration/statistic-assessment-configuration.component.ts +++ b/frontend/src/app/modules/policy-statistics/statistic-assessment-configuration/statistic-assessment-configuration.component.ts @@ -323,7 +323,7 @@ export class StatisticAssessmentConfigurationComponent implements OnInit { } else if (result.length === 1) { return result[0]; } else { - return 'N/A'; + return undefined; } } @@ -337,16 +337,12 @@ export class StatisticAssessmentConfigurationComponent implements OnInit { if (value) { value = value[path[i]] } else { - return ''; + return undefined; } } - if (value) { - return value; - } else { - return ''; - } + return value; } else { - return 'N/A'; + return undefined; } } @@ -380,7 +376,7 @@ export class StatisticAssessmentConfigurationComponent implements OnInit { if (!this.document) { return; } - if(this.scores && this.scores.length) { + if (this.scores && this.scores.length) { this.onStep(2); } else { this.onNextFinish(); @@ -422,12 +418,14 @@ export class StatisticAssessmentConfigurationComponent implements OnInit { for (const formula of this.formulas) { formula.value = this.calcFormula(formula, document); - if (formula.type === 'string') { - formula.value = String(formula.value); - } else { - formula.value = Number(formula.value); + if (formula.value) { + if (formula.type === 'string') { + formula.value = String(formula.value); + } else { + formula.value = Number(formula.value); + } + document[formula.id] = formula.value; } - document[formula.id] = formula.value; } } @@ -453,7 +451,9 @@ export class StatisticAssessmentConfigurationComponent implements OnInit { const document: any = {}; for (const field of this.preview) { - document[field.id] = field.value; + if (field.value !== undefined) { + document[field.id] = field.value; + } } for (const score of this.scores) { const option = score.options.find((o) => o.value === score.value); @@ -486,4 +486,12 @@ export class StatisticAssessmentConfigurationComponent implements OnInit { }; return report; } + + public getVariableValue(value: any): any { + if (value === undefined) { + return 'N/A'; + } else { + return value; + } + } } \ No newline at end of file