File

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

Description

Datatype for the EntitySchemaService transforming values to "number".

This type is automatically used if you annotate a class's property that has the TypeScript type "number" ensuring that even if values in the database from other sources are not of type number they will be cast to number.

For example:

@DatabaseField() myNumber: number;

@DatabaseField({dataType: 'number'}) myValue: any;

Extends

DefaultDatatype

Index

Properties
Methods

Methods

transformToDatabaseFormat
transformToDatabaseFormat(value)
Inherited from DefaultDatatype
Defined in DefaultDatatype:41
Parameters :
Name Optional
value No
Returns : any
transformToObjectFormat
transformToObjectFormat(value)
Inherited from DefaultDatatype
Defined in DefaultDatatype:45
Parameters :
Name Optional
value No
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>
importIncompleteAdditionalConfigBadge
importIncompleteAdditionalConfigBadge(col: ColumnMapping)
Inherited from DefaultDatatype

Output a label indicating whether the given column mapping needs user configuration for the "additional" config or has a valid, complete "additional" config. returns "undefined" if no user action is required.

Parameters :
Name Type Optional
col ColumnMapping No
Returns : string
Async importMapFunction
importMapFunction(val: any, schemaField: EntitySchemaField, additional?: any, importProcessingContext?: any)
Inherited from DefaultDatatype

The function used to map values from the import data to values in the entities to be created. to share information across processing of multiple columns and rows.

Parameters :
Name Type Optional Description
val any No

The value from an imported cell to be mapped

schemaField EntitySchemaField No

The schema field definition for the target property into which the value is mapped

additional any Yes

config as returned by the configComponent

importProcessingContext any Yes

an object that the datatype can use to store any relevant context across multiple calls to share information across processing of multiple columns and rows.

Properties

Static dataType
Type : string
Default value : "number"
Inherited from DefaultDatatype
Defined in DefaultDatatype:35
editComponent
Type : string
Default value : "EditNumber"
Inherited from DefaultDatatype
Defined in DefaultDatatype:39
Static label
Type : string
Default value : $localize`:datatype-label:number`
Inherited from DefaultDatatype
Defined in DefaultDatatype:36
viewComponent
Type : string
Default value : "DisplayText"
Inherited from DefaultDatatype
Defined in DefaultDatatype:38
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.

Optional importConfigComponent
Type : string
Inherited from DefaultDatatype

A component to be display as a dialog to configure the transformation function (e.g. defining a format or mapping)

import { DefaultDatatype } from "../../entity/default-datatype/default.datatype";
import { Injectable } from "@angular/core";

/**
 * Datatype for the EntitySchemaService transforming values to "number".
 *
 * This type is automatically used if you annotate a class's property that has the TypeScript type "number"
 * ensuring that even if values in the database from other sources are not of type number they will be cast to number.
 *
 * For example:
 *
 * `@DatabaseField() myNumber: number;`
 *
 * `@DatabaseField({dataType: 'number'}) myValue: any;`
 */
@Injectable()
export class NumberDatatype extends DefaultDatatype<number, number> {
  static override dataType = "number";
  static override label: string = $localize`:datatype-label:number`;

  override viewComponent = "DisplayText";
  override editComponent = "EditNumber";

  override transformToDatabaseFormat(value) {
    return Number(value);
  }

  override transformToObjectFormat(value) {
    return Number(value);
  }
}

results matching ""

    No results matching ""