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 69c0a35fb5..c5b256ea89 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 @@ -160,7 +160,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig - +
} diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/panel/calculated-field-argument-panel.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/panel/calculated-field-argument-panel.component.ts index 8aa61eb1a4..2a64c90f20 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/panel/calculated-field-argument-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/panel/calculated-field-argument-panel.component.ts @@ -36,12 +36,13 @@ import { EntityId } from '@shared/models/id/entity-id'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { EntityFilter } from '@shared/models/query/query.models'; import { AliasFilterType } from '@shared/models/alias.models'; -import { merge } from 'rxjs'; +import { BehaviorSubject, merge } from 'rxjs'; import { MINUTE } from '@shared/models/time/time.models'; import { getCurrentAuthState } from '@core/auth/auth.selectors'; import { AppState } from '@core/core.state'; import { Store } from '@ngrx/store'; import { EntityAutocompleteComponent } from '@shared/components/entity/entity-autocomplete.component'; +import { NULL_UUID } from '@shared/models/id/has-uuid'; @Component({ selector: 'tb-calculated-field-argument-panel', @@ -51,18 +52,16 @@ import { EntityAutocompleteComponent } from '@shared/components/entity/entity-au export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewInit { @Input() buttonTitle: string; - @Input() index: number; @Input() argument: CalculatedFieldArgumentValue; @Input() entityId: EntityId; @Input() tenantId: string; @Input() entityName: string; - @Input() entityHasError: boolean; @Input() calculatedFieldType: CalculatedFieldType; @Input() usedArgumentNames: string[]; @ViewChild('entityAutocomplete') entityAutocomplete: EntityAutocompleteComponent; - argumentsDataApplied = output<{ value: CalculatedFieldArgumentValue, index: number }>(); + argumentsDataApplied = output(); readonly maxDataPointsPerRollingArg = getCurrentAuthState(this.store).maxDataPointsPerRollingArg; readonly defaultLimit = Math.floor(this.maxDataPointsPerRollingArg / 10); @@ -85,6 +84,7 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewI argumentTypes: ArgumentType[]; entityFilter: EntityFilter; + entityNameSubject = new BehaviorSubject(null); readonly argumentEntityTypes = Object.values(ArgumentEntityType) as ArgumentEntityType[]; readonly ArgumentEntityTypeTranslations = ArgumentEntityTypeTranslations; @@ -106,7 +106,7 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewI private store: Store ) { this.observeEntityFilterChanges(); - this.observeEntityTypeChanges() + this.observeEntityTypeChanges(); this.observeEntityKeyChanges(); this.observeUpdatePosition(); } @@ -141,7 +141,7 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewI } ngAfterViewInit(): void { - if (this.entityHasError) { + if (this.argument.refEntityId?.id === NULL_UUID) { this.entityAutocomplete.selectEntityFormGroup.get('entity').markAsTouched(); } } @@ -152,11 +152,14 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewI if (refEntityId.entityType === ArgumentEntityType.Tenant) { refEntityId.id = this.tenantId; } + if (refEntityId.entityType !== ArgumentEntityType.Current && refEntityId.entityType !== ArgumentEntityType.Tenant) { + value.entityName = this.entityNameSubject.value; + } if (value.defaultValue) { value.defaultValue = value.defaultValue.trim(); } value.refEntityKey.key = value.refEntityKey.key.trim(); - this.argumentsDataApplied.emit({ value, index: this.index }); + this.argumentsDataApplied.emit(value); } cancel(): void { @@ -212,12 +215,16 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewI } private observeEntityTypeChanges(): void { - this.argumentFormGroup.get('refEntityId').get('entityType').valueChanges + this.refEntityIdFormGroup.get('entityType').valueChanges .pipe(distinctUntilChanged(), takeUntilDestroyed()) .subscribe(type => { this.argumentFormGroup.get('refEntityId').get('id').setValue(''); + const isEntityWithId = type !== ArgumentEntityType.Tenant && type !== ArgumentEntityType.Current; this.argumentFormGroup.get('refEntityId') - .get('id')[type === ArgumentEntityType.Tenant || type === ArgumentEntityType.Current ? 'disable' : 'enable'](); + .get('id')[isEntityWithId ? 'enable' : 'disable'](); + if (!isEntityWithId) { + this.entityNameSubject.next(null); + } if (!this.enableAttributeScopeSelection) { this.refEntityKeyFormGroup.get('scope').setValue(AttributeScope.SERVER_SCOPE); } diff --git a/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-button.component.ts b/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-button.component.ts index 85a90aef63..90beed2f7e 100644 --- a/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-button.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-button.component.ts @@ -153,5 +153,6 @@ export class EntityDebugSettingsButtonComponent implements ControlValueAccessor } else { this.debugSettingsFormGroup.enable({emitEvent: false}); } + this.cd.markForCheck(); } } diff --git a/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.html b/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.html index 4a9bc57d8d..5863a295d6 100644 --- a/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.html +++ b/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.html @@ -53,7 +53,7 @@ color="primary" type="button" (click)="onCancel(); additionalActionConfig.action()"> - {{ additionalActionConfig.title | translate }} + {{ additionalActionConfig.title }} } diff --git a/ui-ngx/src/app/shared/models/calculated-field.models.ts b/ui-ngx/src/app/shared/models/calculated-field.models.ts index 383f7c7f72..9cc9a62da8 100644 --- a/ui-ngx/src/app/shared/models/calculated-field.models.ts +++ b/ui-ngx/src/app/shared/models/calculated-field.models.ts @@ -144,6 +144,7 @@ export interface RefEntityId { export interface CalculatedFieldArgumentValue extends CalculatedFieldArgument { argumentName: string; + entityName?: string; } export type CalculatedFieldTestScriptFn = (calculatedField: CalculatedField, argumentsObj?: Record, closeAllOnSave?: boolean) => Observable; diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 1c972fe1c0..88443197ff 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1000,8 +1000,8 @@ "calculated-field": "calculated field", "hint": { "main-limited": "No more than {{msg}} {{entity}} debug messages per {{time}} will be recorded.", - "on-failure": "Log all debug messages.", - "all-messages": "Log error messages only. " + "on-failure": "Log error messages only.", + "all-messages": "Log all debug messages." } }, "calculated-fields": {