Resolved comments
This commit is contained in:
parent
96e292fac5
commit
cfa7066ac6
@ -143,7 +143,7 @@ export class CalculatedFieldArgumentsTableComponent implements ControlValueAcces
|
|||||||
buttonTitle: this.argumentsFormArray.at(index)?.value ? 'action.apply' : 'action.add',
|
buttonTitle: this.argumentsFormArray.at(index)?.value ? 'action.apply' : 'action.add',
|
||||||
tenantId: this.tenantId,
|
tenantId: this.tenantId,
|
||||||
entityName: this.entityName,
|
entityName: this.entityName,
|
||||||
argumentNames: this.argumentsFormArray.value.map(({ argumentName }) => argumentName).filter(name => name !== argumentObj.argumentName),
|
usedArgumentNames: this.argumentsFormArray.value.map(({ argumentName }) => argumentName).filter(name => name !== argumentObj.argumentName),
|
||||||
};
|
};
|
||||||
this.popoverComponent = this.popoverService.displayPopover(trigger, this.renderer,
|
this.popoverComponent = this.popoverService.displayPopover(trigger, this.renderer,
|
||||||
this.viewContainerRef, CalculatedFieldArgumentPanelComponent, 'left', false, null,
|
this.viewContainerRef, CalculatedFieldArgumentPanelComponent, 'left', false, null,
|
||||||
|
|||||||
@ -111,7 +111,7 @@
|
|||||||
<tb-entity-key-autocomplete class="flex-1" formControlName="key" [dataKeyType]="DataKeyType.timeseries" [entityFilter]="entityFilter"/>
|
<tb-entity-key-autocomplete class="flex-1" formControlName="key" [dataKeyType]="DataKeyType.timeseries" [entityFilter]="entityFilter"/>
|
||||||
</div>
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
@if (isDeviceEntity) {
|
@if (enableAttributeScopeSelection) {
|
||||||
<div class="tb-form-row">
|
<div class="tb-form-row">
|
||||||
<div class="fixed-title-width tb-required">{{ 'calculated-fields.attribute-scope' | translate }}</div>
|
<div class="fixed-title-width tb-required">{{ 'calculated-fields.attribute-scope' | translate }}</div>
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic" class="flex-1">
|
<mat-form-field appearance="outline" subscriptSizing="dynamic" class="flex-1">
|
||||||
@ -155,7 +155,7 @@
|
|||||||
<tb-timeinterval
|
<tb-timeinterval
|
||||||
subscriptSizing="dynamic"
|
subscriptSizing="dynamic"
|
||||||
appearance="outline"
|
appearance="outline"
|
||||||
class="time-window-field flex-1"
|
class="flex-1"
|
||||||
formControlName="timeWindow"
|
formControlName="timeWindow"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright © 2016-2024 The Thingsboard Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
:host ::ng-deep {
|
|
||||||
.time-window-field {
|
|
||||||
.mat-mdc-form-field.mat-mdc-form-field.mat-mdc-form-field.mat-mdc-form-field.mat-mdc-form-field.mat-mdc-form-field .mdc-notched-outline__notch {
|
|
||||||
border-left: 1px solid rgba(0, 0, 0, 0) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
import { ChangeDetectorRef, Component, Input, OnInit, output } from '@angular/core';
|
import { ChangeDetectorRef, Component, Input, OnInit, output } from '@angular/core';
|
||||||
import { TbPopoverComponent } from '@shared/components/popover.component';
|
import { TbPopoverComponent } from '@shared/components/popover.component';
|
||||||
import { FormBuilder, FormGroup, UntypedFormControl, ValidatorFn, Validators } from '@angular/forms';
|
import { FormBuilder, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms';
|
||||||
import { charsWithNumRegex, noLeadTrailSpacesRegex } from '@shared/models/regex.constants';
|
import { charsWithNumRegex, noLeadTrailSpacesRegex } from '@shared/models/regex.constants';
|
||||||
import {
|
import {
|
||||||
ArgumentEntityType,
|
ArgumentEntityType,
|
||||||
@ -42,7 +42,6 @@ import { MINUTE } from '@shared/models/time/time.models';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-calculated-field-argument-panel',
|
selector: 'tb-calculated-field-argument-panel',
|
||||||
templateUrl: './calculated-field-argument-panel.component.html',
|
templateUrl: './calculated-field-argument-panel.component.html',
|
||||||
styleUrls: ['./calculated-field-argument-panel.component.scss']
|
|
||||||
})
|
})
|
||||||
export class CalculatedFieldArgumentPanelComponent implements OnInit {
|
export class CalculatedFieldArgumentPanelComponent implements OnInit {
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit {
|
|||||||
@Input() tenantId: string;
|
@Input() tenantId: string;
|
||||||
@Input() entityName: string;
|
@Input() entityName: string;
|
||||||
@Input() calculatedFieldType: CalculatedFieldType;
|
@Input() calculatedFieldType: CalculatedFieldType;
|
||||||
@Input() argumentNames: string[];
|
@Input() usedArgumentNames: string[];
|
||||||
|
|
||||||
argumentsDataApplied = output<{ value: CalculatedFieldArgumentValue, index: number }>();
|
argumentsDataApplied = output<{ value: CalculatedFieldArgumentValue, index: number }>();
|
||||||
|
|
||||||
@ -111,7 +110,7 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit {
|
|||||||
return this.argumentFormGroup.get('refEntityKey') as FormGroup;
|
return this.argumentFormGroup.get('refEntityKey') as FormGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isDeviceEntity(): boolean {
|
get enableAttributeScopeSelection(): boolean {
|
||||||
return this.entityType === ArgumentEntityType.Device
|
return this.entityType === ArgumentEntityType.Device
|
||||||
|| (this.entityType === ArgumentEntityType.Current
|
|| (this.entityType === ArgumentEntityType.Current
|
||||||
&& (this.entityId.entityType === EntityType.DEVICE || this.entityId.entityType === EntityType.DEVICE_PROFILE))
|
&& (this.entityId.entityType === EntityType.DEVICE || this.entityId.entityType === EntityType.DEVICE_PROFILE))
|
||||||
@ -196,16 +195,16 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit {
|
|||||||
this.argumentFormGroup.get('refEntityId').get('id').setValue('');
|
this.argumentFormGroup.get('refEntityId').get('id').setValue('');
|
||||||
this.argumentFormGroup.get('refEntityId')
|
this.argumentFormGroup.get('refEntityId')
|
||||||
.get('id')[type === ArgumentEntityType.Tenant || type === ArgumentEntityType.Current ? 'disable' : 'enable']();
|
.get('id')[type === ArgumentEntityType.Tenant || type === ArgumentEntityType.Current ? 'disable' : 'enable']();
|
||||||
if (!this.isDeviceEntity) {
|
if (!this.enableAttributeScopeSelection) {
|
||||||
this.refEntityKeyFormGroup.get('scope').setValue(AttributeScope.SERVER_SCOPE);
|
this.refEntityKeyFormGroup.get('scope').setValue(AttributeScope.SERVER_SCOPE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private uniqNameRequired(): ValidatorFn {
|
private uniqNameRequired(): ValidatorFn {
|
||||||
return (control: UntypedFormControl) => {
|
return (control: FormControl) => {
|
||||||
const newName = control.value.trim().toLowerCase();
|
const newName = control.value.trim().toLowerCase();
|
||||||
const isDuplicate = this.argumentNames?.some(name => name.toLowerCase() === newName);
|
const isDuplicate = this.usedArgumentNames?.some(name => name.toLowerCase() === newName);
|
||||||
|
|
||||||
return isDuplicate ? { duplicateName: true } : null;
|
return isDuplicate ? { duplicateName: true } : null;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user