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 24d67d8654..b25809ac82 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
@@ -87,19 +87,24 @@
(click)="manageArgument($event, button, $index)"
[matTooltip]="'action.edit' | translate"
matTooltipPosition="above">
- edit
- @if (argumentsFormArray.dirty
- && group.get('refEntityKey').get('type').value === ArgumentType.Rolling
- && calculatedFieldType() === CalculatedFieldType.SIMPLE) {
-
- }
+
+ edit
+
diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/arguments-table/calculated-field-arguments-table.component.scss b/ui-ngx/src/app/modules/home/components/calculated-fields/components/arguments-table/calculated-field-arguments-table.component.scss
index 8f8b1d5d81..3a1f1fbe25 100644
--- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/arguments-table/calculated-field-arguments-table.component.scss
+++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/arguments-table/calculated-field-arguments-table.component.scss
@@ -19,9 +19,10 @@
font-size: 14px;
}
}
- .edit-hint {
- .mat-mdc-form-field-error {
- font-size: 16px;
- }
+}
+
+:host {
+ .field-action {
+ color: rgba(0, 0, 0, 0.54);
}
}
diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts
index 155a384273..55fc299475 100644
--- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts
+++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts
@@ -36,7 +36,6 @@ import { EntityType } from '@shared/models/entity-type.models';
import { map, startWith } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ScriptLanguage } from '@shared/models/rule-node.models';
-import { merge } from 'rxjs';
@Component({
selector: 'tb-calculated-field-dialog',
@@ -60,10 +59,10 @@ export class CalculatedFieldDialogComponent extends DialogComponent Object.keys(this.configFormGroup.get('arguments').value ?? this.data.value.configuration.arguments))
+ startWith(this.data.value?.configuration?.arguments ?? {}),
+ map(argumentsObj => Object.keys(argumentsObj))
);
readonly OutputTypeTranslations = OutputTypeTranslations;
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 fe60162005..510bdd95f3 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
@@ -25,7 +25,8 @@ import {
ArgumentType,
ArgumentTypeTranslations,
CalculatedFieldArgumentValue,
- CalculatedFieldType
+ CalculatedFieldType,
+ getCalculatedFieldCurrentEntityFilter
} from '@shared/models/calculated-field.models';
import { debounceTime, distinctUntilChanged, filter } from 'rxjs/operators';
import { EntityType } from '@shared/models/entity-type.models';
@@ -110,7 +111,7 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit {
ngOnInit(): void {
this.argumentFormGroup.patchValue(this.argument, {emitEvent: false});
- this.currentEntityFilter = this.getCurrentEntityFilter();
+ this.currentEntityFilter = getCalculatedFieldCurrentEntityFilter(this.entityName, this.entityId);
this.updateEntityFilter(this.argument.refEntityId?.entityType, true);
this.toggleByEntityKeyType(this.argument.refEntityKey?.type);
this.setInitialEntityKeyType();
@@ -169,26 +170,6 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit {
this.cd.markForCheck();
}
- private getCurrentEntityFilter(): EntityFilter {
- switch (this.entityId.entityType) {
- case EntityType.ASSET_PROFILE:
- return {
- assetTypes: [this.entityName],
- type: AliasFilterType.assetType
- };
- case EntityType.DEVICE_PROFILE:
- return {
- deviceTypes: [this.entityName],
- type: AliasFilterType.deviceType
- };
- default:
- return {
- type: AliasFilterType.singleEntity,
- singleEntity: this.entityId,
- };
- }
- }
-
private observeEntityFilterChanges(): void {
merge(
this.refEntityIdFormGroup.get('entityType').valueChanges,
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 f73926f62b..fac1e9f942 100644
--- a/ui-ngx/src/app/shared/models/calculated-field.models.ts
+++ b/ui-ngx/src/app/shared/models/calculated-field.models.ts
@@ -20,6 +20,7 @@ import { CalculatedFieldId } from '@shared/models/id/calculated-field-id';
import { EntityId } from '@shared/models/id/entity-id';
import { AttributeScope } from '@shared/models/telemetry/telemetry.models';
import { EntityType } from '@shared/models/entity-type.models';
+import { AliasFilterType } from '@shared/models/alias.models';
export interface CalculatedField extends Omit, 'label'>, HasVersion, HasTenantId {
debugSettings?: EntityDebugSettings;
@@ -133,3 +134,23 @@ export const ArgumentEntityTypeParamsMap =new Map {
+ switch (entityId.entityType) {
+ case EntityType.ASSET_PROFILE:
+ return {
+ assetTypes: [entityName],
+ type: AliasFilterType.assetType
+ };
+ case EntityType.DEVICE_PROFILE:
+ return {
+ deviceTypes: [entityName],
+ type: AliasFilterType.deviceType
+ };
+ default:
+ return {
+ type: AliasFilterType.singleEntity,
+ singleEntity: entityId,
+ };
+ }
+}