From 782cb27643a32c7fcf5f9e14a3a4876cae4972e5 Mon Sep 17 00:00:00 2001 From: Annika Nowak <139357202+anninowak@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:11:48 +0100 Subject: [PATCH] fix: check length of occurences and (#141) check length of occurences before translating and remove const in enum --- .../group-by-count-diagram.component.ts | 18 ++++++++---------- .../src/lib/model/column-type.model.ts | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/libs/portal-integration-angular/src/lib/core/components/group-by-count-diagram/group-by-count-diagram.component.ts b/libs/portal-integration-angular/src/lib/core/components/group-by-count-diagram/group-by-count-diagram.component.ts index 1d0a047f..6d1c6fe4 100644 --- a/libs/portal-integration-angular/src/lib/core/components/group-by-count-diagram/group-by-count-diagram.component.ts +++ b/libs/portal-integration-angular/src/lib/core/components/group-by-count-diagram/group-by-count-diagram.component.ts @@ -64,17 +64,15 @@ export class GroupByCountDiagramComponent implements OnInit { ? (acc.find((e: { label: any }) => e.label === current).value++, acc) : [...acc, { label: current, value: 1 }] }, []) - if (columnType === ColumnType.TRANSLATION_KEY) { - return this.translateService - .get(occurrences.map((o: { label: any }) => o.label)) - .pipe( - map((translations: { [x: string]: any }) => - occurrences.map((o: { label: string; value: any }) => ({ - label: translations[o.label], - value: o.value, - })) - ) + if (columnType === ColumnType.TRANSLATION_KEY && occurrences.length > 0) { + return this.translateService.get(occurrences.map((o: { label: any }) => o.label)).pipe( + map((translations: { [x: string]: any }) => + occurrences.map((o: { label: string; value: any }) => ({ + label: translations[o.label], + value: o.value, + })) ) + ) } else { return of(occurrences) } diff --git a/libs/portal-integration-angular/src/lib/model/column-type.model.ts b/libs/portal-integration-angular/src/lib/model/column-type.model.ts index 142dc802..4181cbda 100644 --- a/libs/portal-integration-angular/src/lib/model/column-type.model.ts +++ b/libs/portal-integration-angular/src/lib/model/column-type.model.ts @@ -1,4 +1,4 @@ -export const enum ColumnType { +export enum ColumnType { STRING = 'STRING', NUMBER = 'NUMBER', DATE = 'DATE',