Resolved PR comments
This commit is contained in:
parent
555acff6b4
commit
d185b78427
@ -87,19 +87,24 @@
|
||||
(click)="manageArgument($event, button, $index)"
|
||||
[matTooltip]="'action.edit' | translate"
|
||||
matTooltipPosition="above">
|
||||
<mat-icon class="opacity-55">edit</mat-icon>
|
||||
@if (argumentsFormArray.dirty
|
||||
<mat-icon
|
||||
[matBadgeHidden]="!(argumentsFormArray.dirty
|
||||
&& group.get('refEntityKey').get('type').value === ArgumentType.Rolling
|
||||
&& calculatedFieldType() === CalculatedFieldType.SIMPLE) {
|
||||
<tb-error class="edit-hint absolute right-0 top-0" [error]="'*'"/>
|
||||
}
|
||||
&& calculatedFieldType() === CalculatedFieldType.SIMPLE)"
|
||||
matBadgeColor="warn"
|
||||
matBadgeSize="small"
|
||||
matBadge="!"
|
||||
class="field-action"
|
||||
>
|
||||
edit
|
||||
</mat-icon>
|
||||
</button>
|
||||
<button type="button"
|
||||
mat-icon-button
|
||||
(click)="onDelete($index)"
|
||||
[matTooltip]="'action.delete' | translate"
|
||||
matTooltipPosition="above">
|
||||
<mat-icon class="opacity-55">delete</mat-icon>
|
||||
<mat-icon class="field-action">delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<CalculatedFi
|
||||
}),
|
||||
});
|
||||
|
||||
functionArgs$ = merge(this.configFormGroup.get('arguments').valueChanges, this.fieldFormGroup.get('type').valueChanges)
|
||||
functionArgs$ = this.configFormGroup.get('arguments').valueChanges
|
||||
.pipe(
|
||||
startWith(null),
|
||||
map(() => 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;
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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<BaseData<CalculatedFieldId>, 'label'>, HasVersion, HasTenantId {
|
||||
debugSettings?: EntityDebugSettings;
|
||||
@ -133,3 +134,23 @@ export const ArgumentEntityTypeParamsMap =new Map<ArgumentEntityType, ArgumentEn
|
||||
[ArgumentEntityType.Asset, { title: 'calculated-fields.asset-name', entityType: EntityType.ASSET }],
|
||||
[ArgumentEntityType.Customer, { title: 'calculated-fields.customer-name', entityType: EntityType.CUSTOMER }],
|
||||
])
|
||||
|
||||
export const getCalculatedFieldCurrentEntityFilter = (entityName: string, entityId: EntityId) => {
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user