File

src/app/core/basic-datatypes/discrete/discrete.datatype.ts

Description

Abstract base for datatypes that hold a discrete set of values.

This provides import config and mapping definitions that work across all such types.

Extends

DefaultDatatype

Index

Properties
Methods

Properties

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 @DatabaseField({dataType: 'foo'}) myField will trigger the datatype implementation with name "foo".

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. @DatabaseField() myField: string is triggering the EntitySchemaDatatype with name "string".

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 DynamicComponent decorator

Methods

importIncompleteAdditionalConfigBadge
importIncompleteAdditionalConfigBadge(col: ColumnMapping)
Inherited from DefaultDatatype
Defined in DefaultDatatype:37
Parameters :
Name Type Optional
col ColumnMapping No
Returns : string
Async importMapFunction
importMapFunction(val, schemaField: EntitySchemaField, additional: literal type)
Inherited from DefaultDatatype
Defined in DefaultDatatype:29
Parameters :
Name Type Optional
val No
schemaField EntitySchemaField No
additional literal type No
Returns : unknown
Abstract transformToDatabaseFormat
transformToDatabaseFormat(value, schemaField?: EntitySchemaField, parent?: Entity)
Inherited from DefaultDatatype
Defined in DefaultDatatype:17
Parameters :
Name Type Optional
value No
schemaField EntitySchemaField Yes
parent Entity Yes
Returns : any
Abstract transformToObjectFormat
transformToObjectFormat(value, schemaField?: EntitySchemaField, parent?: any)
Inherited from DefaultDatatype
Defined in DefaultDatatype:23
Parameters :
Name Type Optional
value No
schemaField EntitySchemaField Yes
parent any Yes
Returns : any
Async anonymize
anonymize(value: EntityType, schemaField: EntitySchemaField, parent: any)
Inherited from DefaultDatatype

(Partially) anonymize to "retain-anonymized" for reporting purposes without personal identifiable information.

Parameters :
Name Type Optional Description
value EntityType No

The original value to be anonymized

schemaField EntitySchemaField No
parent any No
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 },
  ) {
    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;
  }
}

results matching ""

    No results matching ""