|
|
|
@ -46,6 +46,7 @@ import { MatChipGrid } from '@angular/material/chips'; |
|
|
|
import { coerceBooleanProperty } from '@angular/cdk/coercion'; |
|
|
|
import { SubscriptSizing } from '@angular/material/form-field'; |
|
|
|
import { coerceBoolean } from '@shared/decorators/coercion'; |
|
|
|
import { isArray } from 'lodash'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'tb-entity-list', |
|
|
|
@ -196,8 +197,8 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV |
|
|
|
this.entityListFormGroup.get('entities').setValue(this.entities); |
|
|
|
if (this.syncIdsWithDB && this.modelValue.length !== entities.length) { |
|
|
|
this.modelValue = entities.map(entity => entity.id.id); |
|
|
|
this.propagateChange(this.modelValue); |
|
|
|
} |
|
|
|
this.propagateChange(this.modelValue); |
|
|
|
} |
|
|
|
); |
|
|
|
} else { |
|
|
|
@ -209,7 +210,7 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV |
|
|
|
} |
|
|
|
|
|
|
|
validate(): ValidationErrors | null { |
|
|
|
return this.entityListFormGroup.valid ? null : { |
|
|
|
return isArray(this.modelValue) && this.modelValue.length ? null : { |
|
|
|
entities: {valid: false} |
|
|
|
}; |
|
|
|
} |
|
|
|
|