Browse Source

Changed labelText and reqiredText logic

pull/8264/head
kalytka 3 years ago
parent
commit
78ffd10dd3
  1. 4
      ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.html
  2. 21
      ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts

4
ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.html

@ -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>

21
ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts

@ -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;
}
}

Loading…
Cancel
Save