Changed labelText and reqiredText logic

This commit is contained in:
kalytka 2023-03-27 13:52:40 +03:00
parent 464e87fe89
commit 78ffd10dd3
2 changed files with 16 additions and 9 deletions

View File

@ -16,7 +16,7 @@
-->
<mat-form-field [formGroup]="selectEntityFormGroup" class="mat-block" [appearance]="appearance">
<mat-label>{{ entityText | translate }}</mat-label>
<mat-label>{{ label | translate }}</mat-label>
<input matInput type="text"
#entityInput
formControlName="entity"
@ -42,6 +42,6 @@
</mat-option>
</mat-autocomplete>
<mat-error *ngIf="selectEntityFormGroup.get('entity').hasError('required')">
{{ entityRequiredText | translate }}
{{ requiredErrorText | translate }}
</mat-error>
</mat-form-field>

View File

@ -71,7 +71,6 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
this.dirty = true;
}
}
@Input()
set entitySubtype(entitySubtype: string) {
if (this.entitySubtypeValue !== entitySubtype) {
@ -249,12 +248,6 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
break;
}
}
if (this.labelText && this.labelText.length) {
this.entityText = this.labelText;
}
if (this.requiredText && this.requiredText.length) {
this.entityRequiredText = this.requiredText;
}
const currentEntity = this.getCurrentEntity();
if (currentEntity) {
const currentEntityType = currentEntity.id.entityType;
@ -384,4 +377,18 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
}
return entityType;
}
get label(): string {
if (this.labelText && this.labelText.length) {
return this.labelText;
}
return this.entityText;
}
get requiredErrorText(): string {
if (this.requiredText && this.requiredText.length) {
return this.requiredText;
}
return this.entityRequiredText;
}
}