Fixed import of current tenant shows error
This commit is contained in:
parent
60e188a47b
commit
82bb007aaf
@ -37,6 +37,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|||||||
import { CalculatedFieldsService } from '@core/http/calculated-fields.service';
|
import { CalculatedFieldsService } from '@core/http/calculated-fields.service';
|
||||||
import { catchError, filter, switchMap, tap } from 'rxjs/operators';
|
import { catchError, filter, switchMap, tap } from 'rxjs/operators';
|
||||||
import {
|
import {
|
||||||
|
ArgumentEntityType,
|
||||||
ArgumentType,
|
ArgumentType,
|
||||||
CalculatedField,
|
CalculatedField,
|
||||||
CalculatedFieldEventArguments,
|
CalculatedFieldEventArguments,
|
||||||
@ -60,7 +61,7 @@ import { DatePipe } from '@angular/common';
|
|||||||
export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedField> {
|
export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedField> {
|
||||||
|
|
||||||
readonly calculatedFieldsDebugPerTenantLimitsConfiguration =
|
readonly calculatedFieldsDebugPerTenantLimitsConfiguration =
|
||||||
getCurrentAuthState(this.store)['calculatedFieldsDebugPerTenantLimitsConfiguration'] || '1:1';
|
getCurrentAuthState(this.store)['calculatedFieldsDebugPerTenantLimitsConfiguration'];
|
||||||
readonly maxDebugModeDuration = getCurrentAuthState(this.store).maxDebugModeDurationMinutes * MINUTE;
|
readonly maxDebugModeDuration = getCurrentAuthState(this.store).maxDebugModeDurationMinutes * MINUTE;
|
||||||
readonly tenantId = getCurrentAuthUser(this.store).tenantId;
|
readonly tenantId = getCurrentAuthUser(this.store).tenantId;
|
||||||
additionalDebugActionConfig = {
|
additionalDebugActionConfig = {
|
||||||
@ -252,7 +253,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
|
|||||||
this.importExportService.openCalculatedFieldImportDialog()
|
this.importExportService.openCalculatedFieldImportDialog()
|
||||||
.pipe(
|
.pipe(
|
||||||
filter(Boolean),
|
filter(Boolean),
|
||||||
switchMap(calculatedField => this.getCalculatedFieldDialog(calculatedField, 'action.add')),
|
switchMap(calculatedField => this.getCalculatedFieldDialog(this.updateImportedCalculatedField(calculatedField), 'action.add', true)),
|
||||||
filter(Boolean),
|
filter(Boolean),
|
||||||
switchMap(calculatedField => this.calculatedFieldsService.saveCalculatedField(calculatedField)),
|
switchMap(calculatedField => this.calculatedFieldsService.saveCalculatedField(calculatedField)),
|
||||||
filter(Boolean),
|
filter(Boolean),
|
||||||
@ -261,6 +262,22 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
|
|||||||
.subscribe(() => this.updateData());
|
.subscribe(() => 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 {
|
private onDebugConfigChanged(id: string, debugSettings: EntityDebugSettings): void {
|
||||||
this.calculatedFieldsService.getCalculatedFieldById(id).pipe(
|
this.calculatedFieldsService.getCalculatedFieldById(id).pipe(
|
||||||
switchMap(field => this.calculatedFieldsService.saveCalculatedField({ ...field, debugSettings })),
|
switchMap(field => this.calculatedFieldsService.saveCalculatedField({ ...field, debugSettings })),
|
||||||
|
|||||||
@ -58,7 +58,7 @@
|
|||||||
</mat-header-cell>
|
</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let argument" class="w-1/4 xs:hidden">
|
<mat-cell *matCellDef="let argument" class="w-1/4 xs:hidden">
|
||||||
<div tbTruncateWithTooltip>
|
<div tbTruncateWithTooltip>
|
||||||
@if (argument.refEntityId?.id) {
|
@if (argument.refEntityId?.id && argument.refEntityId?.entityType !== ArgumentEntityType.Tenant) {
|
||||||
<a aria-label="Open entity details page"
|
<a aria-label="Open entity details page"
|
||||||
[routerLink]="getEntityDetailsPageURL(argument.refEntityId.id, argument.refEntityId.entityType)">
|
[routerLink]="getEntityDetailsPageURL(argument.refEntityId.id, argument.refEntityId.entityType)">
|
||||||
{{ entityNameMap.get(argument.refEntityId.id) ?? '' }}
|
{{ entityNameMap.get(argument.refEntityId.id) ?? '' }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user