Hide entity field in collection form when entities aren't initialized

This commit is contained in:
Alexandre Vryghem
2023-06-30 20:23:51 +02:00
parent ca864379c8
commit b2b1782cd8

View File

@@ -79,9 +79,8 @@ export class CollectionFormComponent extends ComColFormComponent<Collection> imp
// retrieve all entity types to populate the dropdowns selection
entities$.subscribe((entityTypes: ItemType[]) => {
entityTypes
.filter((type: ItemType) => type.label !== NONE_ENTITY_TYPE)
.forEach((type: ItemType, index: number) => {
entityTypes = entityTypes.filter((type: ItemType) => type.label !== NONE_ENTITY_TYPE);
entityTypes.forEach((type: ItemType, index: number) => {
this.entityTypeSelection.add({
disabled: false,
label: type.label,
@@ -93,7 +92,7 @@ export class CollectionFormComponent extends ComColFormComponent<Collection> imp
}
});
this.formModel = [...collectionFormModels, this.entityTypeSelection];
this.formModel = entityTypes.length === 0 ? collectionFormModels : [...collectionFormModels, this.entityTypeSelection];
super.ngOnInit();
});