82 lines
3.5 KiB
HTML
82 lines
3.5 KiB
HTML
<!--
|
|
|
|
Copyright © 2016-2025 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.
|
|
|
|
-->
|
|
<mat-form-field [formGroup]="selectEntityFormGroup"
|
|
[class.tb-inline-field]="inlineField"
|
|
[class.flex]="inlineField"
|
|
[class.tb-suffix-absolute]="inlineField && !selectEntityFormGroup.get('entity').value"
|
|
class="mat-block"
|
|
[appearance]="inlineField ? 'outline' : appearance"
|
|
[subscriptSizing]="inlineField ? 'dynamic' : subscriptSizing"
|
|
[class]="additionalClasses">
|
|
<mat-label *ngIf="!inlineField">{{ label | translate }}</mat-label>
|
|
<input matInput type="text"
|
|
#entityInput
|
|
placeholder="{{ placeholder }}"
|
|
formControlName="entity"
|
|
(focusin)="onFocus()"
|
|
[required]="required"
|
|
[matAutocomplete]="entityAutocomplete"
|
|
[class.!hidden]="showEntityLink">
|
|
<a *ngIf="showEntityLink" aria-label="Open entity details page" [routerLink]=entityURL>
|
|
{{ displayEntityFn(selectEntityFormGroup.get('entity').value) }}
|
|
</a>
|
|
<button *ngIf="selectEntityFormGroup.get('entity').value && !disabled"
|
|
type="button"
|
|
matSuffix mat-icon-button aria-label="Clear"
|
|
(click)="clear()">
|
|
<mat-icon class="material-icons">close</mat-icon>
|
|
</button>
|
|
<button mat-button color="primary" matSuffix
|
|
type="button"
|
|
*ngIf="allowCreateNew && !selectEntityFormGroup.get('entity').value && !disabled"
|
|
(click)="createNewEntity($event)">
|
|
<span style="white-space: nowrap">{{ 'entity.create-new' | translate }}</span>
|
|
</button>
|
|
<mat-icon matSuffix
|
|
matTooltipPosition="above"
|
|
matTooltipClass="tb-error-tooltip"
|
|
[matTooltip]="requiredErrorText | translate"
|
|
*ngIf="inlineField && selectEntityFormGroup.get('entity').hasError('required')
|
|
&& selectEntityFormGroup.get('entity').touched"
|
|
class="tb-error">
|
|
warning
|
|
</mat-icon>
|
|
<mat-autocomplete class="tb-autocomplete"
|
|
#entityAutocomplete="matAutocomplete"
|
|
[displayWith]="displayEntityFn">
|
|
<mat-option *ngFor="let entity of filteredEntities | async" [value]="entity">
|
|
<span [innerHTML]="entity.name | highlight:searchText:true:'ig'"></span>
|
|
</mat-option>
|
|
<mat-option *ngIf="!(filteredEntities | async)?.length" [value]="null">
|
|
<div (click)="$event.stopPropagation()">
|
|
<div *ngIf="!textIsNotEmpty(searchText); else searchNotEmpty">
|
|
<span>{{ notFoundEntities | translate }}</span>
|
|
</div>
|
|
<ng-template #searchNotEmpty>
|
|
<span>
|
|
{{ noEntitiesMatchingText | translate: {entity: searchText} }}
|
|
</span>
|
|
</ng-template>
|
|
</div>
|
|
</mat-option>
|
|
</mat-autocomplete>
|
|
<mat-error *ngIf="!inlineField && selectEntityFormGroup.get('entity').hasError('required')">
|
|
{{ requiredErrorText | translate }}
|
|
</mat-error>
|
|
</mat-form-field>
|