src/app/core/basic-datatypes/string/string.datatype.ts
Datatype for the EntitySchemaService transforming values to "string".
This type is automatically used if you annotate a class's property that has the TypeScript type "string" ensuring that even if values in the database from other sources are not of type string, the property will be a string.
For example:
@DatabaseField() myString: string;
@DatabaseField({dataType: 'string'}) myValue: any;
Properties |
|
Methods |
| transformToDatabaseFormat | ||||||
transformToDatabaseFormat(value: unknown)
|
||||||
|
Inherited from
DefaultDatatype
|
||||||
|
Defined in
DefaultDatatype:38
|
||||||
|
Parameters :
Returns :
any
|
| transformToObjectFormat | ||||||
transformToObjectFormat(value: unknown)
|
||||||
|
Inherited from
DefaultDatatype
|
||||||
|
Defined in
DefaultDatatype:45
|
||||||
|
Parameters :
Returns :
any
|
| Async anonymize | ||||||||||||||||
anonymize(value: EntityType, schemaField: EntitySchemaField, parent: any)
|
||||||||||||||||
|
Inherited from
DefaultDatatype
|
||||||||||||||||
|
Defined in
DefaultDatatype:190
|
||||||||||||||||
|
(Partially) anonymize to "retain-anonymized" for reporting purposes without personal identifiable information.
Parameters :
Returns :
Promise<any>
|
| Static detectFieldInEntity | ||||||||||||
detectFieldInEntity(entityOrType: Entity | EntityConstructor, dataTypes: string | string[])
|
||||||||||||
|
Inherited from
DefaultDatatype
|
||||||||||||
|
Defined in
DefaultDatatype:57
|
||||||||||||
|
Detect the first field of the given datatype(s) in an entity's schema. Scans the schema for a field whose Subclasses typically override this without the extra
Parameters :
Returns :
string | undefined
The field name of the first matching field, or |
| importIncompleteAdditionalConfigBadge | ||||||
importIncompleteAdditionalConfigBadge(col: ColumnMapping)
|
||||||
|
Inherited from
DefaultDatatype
|
||||||
|
Defined in
DefaultDatatype:166
|
||||||
|
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 :
Returns :
string
|
| Async importMapFunction | ||||||||||||||||||||
importMapFunction(val: any, schemaField: EntitySchemaField, additional?: any, importProcessingContext?: any)
|
||||||||||||||||||||
|
Inherited from
DefaultDatatype
|
||||||||||||||||||||
|
Defined in
DefaultDatatype:145
|
||||||||||||||||||||
|
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 :
Returns :
Promise<EntityType>
|
| normalizeSchemaField | ||||||||
normalizeSchemaField(schemaField: EntitySchemaField)
|
||||||||
|
Inherited from
DefaultDatatype
|
||||||||
|
Defined in
DefaultDatatype:182
|
||||||||
|
Return the (potentially adjusted) schema field for this datatype. Called when schema fields are set up (e.g. from config), allowing the datatype to normalize or fill in required settings. Override this in a subclass to enforce constraints
(e.g. always setting
Parameters :
Returns :
EntitySchemaField
The schema field to use (default: unchanged) |
| Static dataType |
Type : string
|
Default value : "string"
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:35
|
| Static label |
Type : string
|
Default value : $localize`:datatype-label:text`
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:36
|
| editComponent |
Type : string
|
Default value : "EditText"
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:101
|
| Readonly importAllowsMultiMapping |
Type : boolean
|
Default value : false
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:80
|
|
Whether this datatype allows multiple values to be mapped to the same entity field during import. |
| Optional importConfigComponent |
Type : string
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:158
|
|
A component to be display as a dialog to configure the transformation function (e.g. defining a format or mapping) |
| viewComponent |
Type : string
|
Default value : "DisplayText"
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:100
|
|
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 |
import { Injectable } from "@angular/core";
import { DefaultDatatype } from "../../entity/default-datatype/default.datatype";
/**
* Datatype for the EntitySchemaService transforming values to "string".
*
* This type is automatically used if you annotate a class's property that has the TypeScript type "string"
* ensuring that even if values in the database from other sources are not of type string, the property will be a string.
*
* For example:
*
* `@DatabaseField() myString: string;`
*
* `@DatabaseField({dataType: 'string'}) myValue: any;`
*/
@Injectable()
export class StringDatatype extends DefaultDatatype<string, string> {
static override dataType = "string";
static override label: string = $localize`:datatype-label:text`;
override transformToDatabaseFormat(value) {
if (value === null || value === undefined) {
return value;
}
return String(value);
}
override transformToObjectFormat(value) {
if (value === null || value === undefined) {
return value;
}
return String(value);
}
}