src/app/core/basic-datatypes/discrete/discrete.datatype.ts
Abstract base for datatypes that hold a discrete set of values.
This provides import config and mapping definitions that work across all such types.
Properties |
|
Methods |
|
| importConfigComponent |
Type : string
|
Default value : "DiscreteImportConfig"
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:15
|
| Static dataType |
Type : string
|
Default value : ""
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:42
|
|
Key for this datatype that must be specified in the DatabaseField annotation to use this transformation. for example If you set the name to a TypeScript type, class properties with this type will automatically use
that EntitySchemaDatatype without the need to explicitly state the dataType config in the annotation
(e.g. |
| editComponent |
Type : string
|
Default value : "EditText"
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:69
|
| Readonly importAllowsMultiMapping |
Type : boolean
|
Default value : false
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:48
|
|
Whether this datatype allows multiple values to be mapped to the same entity field during import. |
| Static label |
Type : string
|
Default value : $localize`:datatype-label:any`
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:57
|
|
The human-readable name for this dataType, used in config UIs. |
| viewComponent |
Type : string
|
Default value : "DisplayText"
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:68
|
|
The default component how this datatype should be displayed in lists and forms. The edit component has to be a registered component. Components that are registered contain the |
| importIncompleteAdditionalConfigBadge | ||||||
importIncompleteAdditionalConfigBadge(col: ColumnMapping)
|
||||||
|
Inherited from
DefaultDatatype
|
||||||
|
Defined in
DefaultDatatype:49
|
||||||
|
Parameters :
Returns :
string
|
| Async importMapFunction | ||||||||||||
importMapFunction(val: unknown, schemaField: EntitySchemaField, additional: literal type)
|
||||||||||||
|
Inherited from
DefaultDatatype
|
||||||||||||
|
Defined in
DefaultDatatype:29
|
||||||||||||
|
Parameters :
Returns :
unknown
|
| Abstract transformToDatabaseFormat | ||||||||||||
transformToDatabaseFormat(value: unknown, schemaField?: EntitySchemaField, parent?: Entity)
|
||||||||||||
|
Inherited from
DefaultDatatype
|
||||||||||||
|
Defined in
DefaultDatatype:17
|
||||||||||||
|
Parameters :
Returns :
any
|
| Abstract transformToObjectFormat | ||||||||||||
transformToObjectFormat(value: unknown, schemaField?: EntitySchemaField, parent?: any)
|
||||||||||||
|
Inherited from
DefaultDatatype
|
||||||||||||
|
Defined in
DefaultDatatype:23
|
||||||||||||
|
Parameters :
Returns :
any
|
| Async anonymize | ||||||||||||||||
anonymize(value: EntityType, schemaField: EntitySchemaField, parent: any)
|
||||||||||||||||
|
Inherited from
DefaultDatatype
|
||||||||||||||||
|
Defined in
DefaultDatatype:148
|
||||||||||||||||
|
(Partially) anonymize to "retain-anonymized" for reporting purposes without personal identifiable information.
Parameters :
Returns :
Promise<any>
|
import { DefaultDatatype } from "../../entity/default-datatype/default.datatype";
import { EntitySchemaField } from "../../entity/schema/entity-schema-field";
import { ColumnMapping } from "../../import/column-mapping";
import { Entity } from "../../entity/model/entity";
/**
* Abstract base for datatypes that hold a discrete set of values.
*
* This provides import config and mapping definitions that work across all such types.
*/
export abstract class DiscreteDatatype<
EntityType,
DBType,
> extends DefaultDatatype<EntityType, DBType> {
override importConfigComponent = "DiscreteImportConfig";
abstract override transformToDatabaseFormat(
value,
schemaField?: EntitySchemaField,
parent?: Entity,
);
abstract override transformToObjectFormat(
value,
schemaField?: EntitySchemaField,
parent?: any,
);
override async importMapFunction(
val,
schemaField: EntitySchemaField,
additional: { [key: string]: any },
) {
// If mapping dialog was skipped entirely,
// treat as raw string value and let transformToObjectFormat handle it
if (!additional) {
return super.importMapFunction(val, schemaField);
}
// If mapping dialog was opened but this specific value was not mapped,
// skip the property by returning undefined
if (additional[val] === undefined) {
return undefined;
}
return super.importMapFunction(additional[val], schemaField);
}
override importIncompleteAdditionalConfigBadge(col: ColumnMapping): string {
if (!col.additional) {
return "?";
}
const unmappedValues = Object.values(col.additional).filter(
(v) => v === undefined,
);
if (unmappedValues.length > 0) {
return unmappedValues.length.toString();
}
return undefined;
}
}