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 // retrieve all entity types to populate the dropdowns selection
entities$.subscribe((entityTypes: ItemType[]) => { entities$.subscribe((entityTypes: ItemType[]) => {
entityTypes entityTypes = entityTypes.filter((type: ItemType) => type.label !== NONE_ENTITY_TYPE);
.filter((type: ItemType) => type.label !== NONE_ENTITY_TYPE) entityTypes.forEach((type: ItemType, index: number) => {
.forEach((type: ItemType, index: number) => {
this.entityTypeSelection.add({ this.entityTypeSelection.add({
disabled: false, disabled: false,
label: type.label, 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(); super.ngOnInit();
}); });