UI: Refactoring

This commit is contained in:
Artem Dzhereleiko 2024-08-05 10:21:51 +03:00
parent e74d6f4534
commit eb66fd30cc

View File

@ -56,11 +56,6 @@ import { coerceBoolean } from '@shared/decorators/coercion';
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => EntityListComponent),
multi: true
},
{
provide: NG_VALIDATORS,
useExisting: forwardRef(() => EntityListComponent),
multi: true
}
]
})
@ -194,7 +189,8 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV
(entities) => {
this.entities = entities;
this.entityListFormGroup.get('entities').setValue(this.entities);
if (this.syncedIdListPropagator) {
if (this.syncedIdListPropagator && this.modelValue.length !== entities.length) {
this.modelValue = entities.map(entity => entity.id.id);
this.propagateChange(this.modelValue);
}
}
@ -207,12 +203,6 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV
this.dirty = true;
}
validate(): ValidationErrors | null {
return this.entityListFormGroup.valid ? null : {
entities: {valid: false}
};
}
private reset() {
this.entities = [];
this.entityListFormGroup.get('entities').setValue(this.entities);