From 82bb007aaf909a346142f657b0559e4868433f7a Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 19 Mar 2025 15:43:20 +0200 Subject: [PATCH 1/3] Fixed import of current tenant shows error --- .../calculated-fields-table-config.ts | 21 +++++++++++++++++-- ...lated-field-arguments-table.component.html | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts index 1cf44966fc..37dc5d69e7 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts @@ -37,6 +37,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { CalculatedFieldsService } from '@core/http/calculated-fields.service'; import { catchError, filter, switchMap, tap } from 'rxjs/operators'; import { + ArgumentEntityType, ArgumentType, CalculatedField, CalculatedFieldEventArguments, @@ -60,7 +61,7 @@ import { DatePipe } from '@angular/common'; export class CalculatedFieldsTableConfig extends EntityTableConfig { readonly calculatedFieldsDebugPerTenantLimitsConfiguration = - getCurrentAuthState(this.store)['calculatedFieldsDebugPerTenantLimitsConfiguration'] || '1:1'; + getCurrentAuthState(this.store)['calculatedFieldsDebugPerTenantLimitsConfiguration']; readonly maxDebugModeDuration = getCurrentAuthState(this.store).maxDebugModeDurationMinutes * MINUTE; readonly tenantId = getCurrentAuthUser(this.store).tenantId; additionalDebugActionConfig = { @@ -252,7 +253,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig this.getCalculatedFieldDialog(calculatedField, 'action.add')), + switchMap(calculatedField => this.getCalculatedFieldDialog(this.updateImportedCalculatedField(calculatedField), 'action.add', true)), filter(Boolean), switchMap(calculatedField => this.calculatedFieldsService.saveCalculatedField(calculatedField)), filter(Boolean), @@ -261,6 +262,22 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig this.updateData()); } + private updateImportedCalculatedField(calculatedField: CalculatedField): CalculatedField { + return { + ...calculatedField, + configuration: { + ...calculatedField.configuration, + arguments: Object.keys(calculatedField.configuration.arguments).reduce((acc, key) => { + const arg = calculatedField.configuration.arguments[key]; + acc[key] = arg.refEntityId?.entityType === ArgumentEntityType.Tenant + ? { ...arg, refEntityId: { id: this.tenantId, entityType: ArgumentEntityType.Tenant } } + : arg; + return acc; + }, {}) + } + } + } + private onDebugConfigChanged(id: string, debugSettings: EntityDebugSettings): void { this.calculatedFieldsService.getCalculatedFieldById(id).pipe( switchMap(field => this.calculatedFieldsService.saveCalculatedField({ ...field, debugSettings })), diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/arguments-table/calculated-field-arguments-table.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/arguments-table/calculated-field-arguments-table.component.html index abb34cb502..39cd4b757c 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/arguments-table/calculated-field-arguments-table.component.html +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/arguments-table/calculated-field-arguments-table.component.html @@ -58,7 +58,7 @@
- @if (argument.refEntityId?.id) { + @if (argument.refEntityId?.id && argument.refEntityId?.entityType !== ArgumentEntityType.Tenant) { {{ entityNameMap.get(argument.refEntityId.id) ?? '' }} From 47232a629bf79ef1b7a47c80696bc7bd1ed81473 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 19 Mar 2025 17:20:01 +0200 Subject: [PATCH 2/3] refactoring --- .../calculated-fields-table-config.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts index 37dc5d69e7..cc4a100b2b 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts @@ -263,18 +263,17 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig { + const arg = calculatedField.configuration.arguments[key]; + acc[key] = arg.refEntityId?.entityType === ArgumentEntityType.Tenant + ? { ...arg, refEntityId: { id: this.tenantId, entityType: ArgumentEntityType.Tenant } } + : arg; + return acc; + }, {}); + return { ...calculatedField, - configuration: { - ...calculatedField.configuration, - arguments: Object.keys(calculatedField.configuration.arguments).reduce((acc, key) => { - const arg = calculatedField.configuration.arguments[key]; - acc[key] = arg.refEntityId?.entityType === ArgumentEntityType.Tenant - ? { ...arg, refEntityId: { id: this.tenantId, entityType: ArgumentEntityType.Tenant } } - : arg; - return acc; - }, {}) - } + configuration: { ...calculatedField.configuration, arguments: updatedArguments } } } From 1cc03d63e2582938729bf0b7e47adfb48c0432ae Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 19 Mar 2025 17:33:11 +0200 Subject: [PATCH 3/3] refactoring --- .../calculated-fields/calculated-fields-table-config.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts index cc4a100b2b..69c0a35fb5 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts @@ -263,7 +263,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig { + calculatedField.configuration.arguments = Object.keys(calculatedField.configuration.arguments).reduce((acc, key) => { const arg = calculatedField.configuration.arguments[key]; acc[key] = arg.refEntityId?.entityType === ArgumentEntityType.Tenant ? { ...arg, refEntityId: { id: this.tenantId, entityType: ArgumentEntityType.Tenant } } @@ -271,10 +271,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig