diff --git a/src/app/core/configurable-enum/configurable-enum-datatype/configurable-enum-datatype.ts b/src/app/core/configurable-enum/configurable-enum-datatype/configurable-enum-datatype.ts index a2b6477db2..e946fc8ead 100644 --- a/src/app/core/configurable-enum/configurable-enum-datatype/configurable-enum-datatype.ts +++ b/src/app/core/configurable-enum/configurable-enum-datatype/configurable-enum-datatype.ts @@ -2,6 +2,7 @@ import { EntitySchemaDatatype } from "../../entity/schema/entity-schema-datatype import { ConfigurableEnumValue } from "../configurable-enum.interface"; import { EntitySchemaField } from "../../entity/schema/entity-schema-field"; import { ConfigurableEnumService } from "../configurable-enum.service"; +import { LoggingService } from "../../logging/logging.service"; export class ConfigurableEnumDatatype implements EntitySchemaDatatype @@ -10,7 +11,10 @@ export class ConfigurableEnumDatatype public readonly viewComponent = "DisplayConfigurableEnum"; public readonly editComponent = "EditConfigurableEnum"; - constructor(private enumService: ConfigurableEnumService) {} + constructor( + private enumService: ConfigurableEnumService, + private logger: LoggingService = new LoggingService() + ) {} /** * transforms Objects of InteractionType to strings to save in DB @@ -33,7 +37,13 @@ export class ConfigurableEnumDatatype let enumOption = this.enumService .getEnumValues(enumId) ?.find((option) => option.id === value); - if (!enumOption) { + if (!enumOption && value) { + const loadedEnums = this.enumService["enums"] + ? [...this.enumService["enums"].keys()].toString() + : "NONE LOADED"; + this.logger.warn( + `invalid enum option: ${value} for enum: ${enumId}; existing enums: ${loadedEnums}` + ); enumOption = this.generateOptionForInvalid(value); } diff --git a/src/app/core/configurable-enum/configurable-enum.module.ts b/src/app/core/configurable-enum/configurable-enum.module.ts index 54d48356c5..b1f1e635c3 100644 --- a/src/app/core/configurable-enum/configurable-enum.module.ts +++ b/src/app/core/configurable-enum/configurable-enum.module.ts @@ -2,6 +2,7 @@ import { NgModule } from "@angular/core"; import { EntitySchemaService } from "../entity/schema/entity-schema.service"; import { ConfigurableEnumDatatype } from "./configurable-enum-datatype/configurable-enum-datatype"; import { ConfigurableEnumService } from "./configurable-enum.service"; +import { LoggingService } from "../logging/logging.service"; /** * Provides a generic functionality to define enums (collections of selectable options) in the config database @@ -47,12 +48,13 @@ import { ConfigurableEnumService } from "./configurable-enum.service"; @NgModule({}) export class ConfigurableEnumModule { constructor( - private enumService: ConfigurableEnumService, - private entitySchemaService: EntitySchemaService + enumService: ConfigurableEnumService, + entitySchemaService: EntitySchemaService, + logger: LoggingService ) { - this.entitySchemaService.registerSchemaDatatype( - new ConfigurableEnumDatatype(enumService) - ); enumService.preLoadEnums(); + entitySchemaService.registerSchemaDatatype( + new ConfigurableEnumDatatype(enumService, logger) + ); } }