src/app/core/basic-datatypes/date-with-age/date-with-age.datatype.ts
Similar to the 'date-only' datatype but it uses the DateWithAge class which provides the age function.
Properties |
|
Methods |
| transformToObjectFormat | ||||||||||||
transformToObjectFormat(value: unknown, schemaField: EntitySchemaField, parent: any)
|
||||||||||||
|
Inherited from
DefaultDatatype
|
||||||||||||
|
Defined in
DefaultDatatype:16
|
||||||||||||
|
Parameters :
Returns :
DateWithAge
|
| transformToDatabaseFormat | ||||||
transformToDatabaseFormat(value: Date)
|
||||||
|
Inherited from
DefaultDatatype
|
||||||
|
Defined in
DefaultDatatype:37
|
||||||
|
Parameters :
Returns :
any
|
| Async anonymize | ||||||
anonymize(value: Date)
|
||||||
|
Inherited from
DefaultDatatype
|
||||||
|
Defined in
DefaultDatatype:91
|
||||||
|
Parameters :
Returns :
Promise<Date>
|
| Static detectFieldInEntity | ||||||
detectFieldInEntity(entityOrType: Entity | EntityConstructor)
|
||||||
|
Inherited from
DefaultDatatype
|
||||||
|
Defined in
DefaultDatatype:45
|
||||||
|
Parameters :
Returns :
string | undefined
|
| Async importMapFunction | ||||||||||||
importMapFunction(val: any, schemaField?: EntitySchemaField | undefined, additional?: any)
|
||||||||||||
|
Inherited from
DefaultDatatype
|
||||||||||||
|
Defined in
DefaultDatatype:78
|
||||||||||||
|
Parameters :
Returns :
unknown
|
| 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
|
| 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 : "date-with-age"
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:11
|
| editComponent |
Type : string
|
Default value : "EditAge"
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:14
|
| Static label |
Type : string
|
Default value : $localize`:datatype-label:date of birth (date + age)`
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:12
|
| importConfigComponent |
Type : string
|
Default value : "DateImportConfig"
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:76
|
| viewComponent |
Type : string
|
Default value : "DisplayDate"
|
|
Inherited from
DefaultDatatype
|
|
Defined in
DefaultDatatype:54
|
| 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. |
import { DateOnlyDatatype } from "../date-only/date-only.datatype";
import { Injectable } from "@angular/core";
import { DateWithAge } from "./dateWithAge";
import { EntitySchemaField } from "../../entity/schema/entity-schema-field";
/**
* Similar to the 'date-only' datatype but it uses the `DateWithAge` class which provides the `age` function.
*/
@Injectable()
export class DateWithAgeDatatype extends DateOnlyDatatype {
static override dataType = "date-with-age";
static override label: string = $localize`:datatype-label:date of birth (date + age)`;
override editComponent = "EditAge";
override transformToObjectFormat(
value,
schemaField: EntitySchemaField,
parent: any,
): DateWithAge {
const dateValue = super.transformToObjectFormat(value, schemaField, parent);
if (!dateValue) {
return undefined;
}
return new DateWithAge(dateValue);
}
}