diff --git a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.html b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.html
index 2b69495a3c..6d8a424352 100644
--- a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.html
+++ b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.html
@@ -16,7 +16,7 @@
-->
- {{ entityText | translate }}
+ {{ label | translate }}
- {{ entityRequiredText | translate }}
+ {{ requiredErrorText | translate }}
diff --git a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts
index 687bd003ea..6a7e6c087c 100644
--- a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts
+++ b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts
@@ -36,10 +36,10 @@ import { AliasEntityType, EntityType } from '@shared/models/entity-type.models';
import { BaseData } from '@shared/models/base-data';
import { EntityId } from '@shared/models/id/entity-id';
import { EntityService } from '@core/http/entity.service';
-import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { Authority } from '@shared/models/authority.enum';
import { isEqual } from '@core/utils';
+import { coerceBoolean } from '@shared/decorators/coerce-boolean';
@Component({
selector: 'tb-entity-autocomplete',
@@ -61,6 +61,22 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
entitySubtypeValue: string;
+ entityText: string;
+
+ noEntitiesMatchingText: string;
+
+ entityRequiredText: string;
+
+ filteredEntities: Observable>>;
+
+ searchText = '';
+
+ private dirty = false;
+
+ private refresh$ = new Subject>>();
+
+ private propagateChange = (v: any) => { };
+
@Input()
set entityType(entityType: EntityType) {
if (this.entityTypeValue !== entityType) {
@@ -100,16 +116,12 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
@Input()
appearance: MatFormFieldAppearance = 'fill';
- private requiredValue: boolean;
- get required(): boolean {
- return this.requiredValue;
- }
@Input()
- set required(value: boolean) {
- this.requiredValue = coerceBooleanProperty(value);
- }
+ @coerceBoolean()
+ required: boolean;
@Input()
+ @coerceBoolean()
disabled: boolean;
@Output()
@@ -117,19 +129,20 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
@ViewChild('entityInput', {static: true}) entityInput: ElementRef;
- entityText: string;
- noEntitiesMatchingText: string;
- entityRequiredText: string;
-
- filteredEntities: Observable>>;
-
- searchText = '';
-
- private dirty = false;
+ get requiredErrorText(): string {
+ if (this.requiredText && this.requiredText.length) {
+ return this.requiredText;
+ }
+ return this.entityRequiredText;
+ }
- private refresh$ = new Subject>>();
+ get label(): string {
+ if (this.labelText && this.labelText.length) {
+ return this.labelText;
+ }
+ return this.entityText;
+ }
- private propagateChange = (v: any) => { };
constructor(private store: Store,
public translate: TranslateService,
@@ -249,12 +262,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;