## Introduction This PR enables functionality discussed in [Layout Date Formatting](https://github.com/twentyhq/core-team-issues/issues/97). ### TLDR; It enables greater control of date formatting at the object's field level by upgrading all DATE and DATE_TIME fields' settings from: ```ts { displayAsRelativeDate: boolean } ``` to: ```ts type FieldDateDisplayFormat = 'full_date' | 'relative_date' | 'date' | 'time' | 'year' | 'custom' { displayFormat: FieldDateDisplayFormat } ``` PR also includes an upgrade command that will update any existing DATE and DATE_TIME fields to the new settings value --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: Félix Malfait <felix@twenty.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
64 lines
2.1 KiB
TypeScript
64 lines
2.1 KiB
TypeScript
import { msg } from '@lingui/core/macro';
|
|
import { FieldMetadataType } from 'twenty-shared/types';
|
|
|
|
import { DateDisplayFormat } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-settings.interface';
|
|
|
|
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
|
|
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
|
|
import { WorkspaceIsPrimaryField } from 'src/engine/twenty-orm/decorators/workspace-is-primary-field.decorator';
|
|
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
|
|
import { BASE_OBJECT_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
|
|
|
export abstract class BaseWorkspaceEntity {
|
|
@WorkspaceField({
|
|
standardId: BASE_OBJECT_STANDARD_FIELD_IDS.id,
|
|
type: FieldMetadataType.UUID,
|
|
label: msg`Id`,
|
|
description: msg`Id`,
|
|
defaultValue: 'uuid',
|
|
icon: 'Icon123',
|
|
})
|
|
@WorkspaceIsPrimaryField()
|
|
@WorkspaceIsSystem()
|
|
id: string;
|
|
|
|
@WorkspaceField({
|
|
standardId: BASE_OBJECT_STANDARD_FIELD_IDS.createdAt,
|
|
type: FieldMetadataType.DATE_TIME,
|
|
label: msg`Creation date`,
|
|
description: msg`Creation date`,
|
|
icon: 'IconCalendar',
|
|
defaultValue: 'now',
|
|
settings: {
|
|
displayFormat: DateDisplayFormat.RELATIVE,
|
|
},
|
|
})
|
|
createdAt: string;
|
|
|
|
@WorkspaceField({
|
|
standardId: BASE_OBJECT_STANDARD_FIELD_IDS.updatedAt,
|
|
type: FieldMetadataType.DATE_TIME,
|
|
label: msg`Last update`,
|
|
description: msg`Last time the record was changed`,
|
|
icon: 'IconCalendarClock',
|
|
defaultValue: 'now',
|
|
settings: {
|
|
displayFormat: DateDisplayFormat.RELATIVE,
|
|
},
|
|
})
|
|
updatedAt: string;
|
|
|
|
@WorkspaceField({
|
|
standardId: BASE_OBJECT_STANDARD_FIELD_IDS.deletedAt,
|
|
type: FieldMetadataType.DATE_TIME,
|
|
label: msg`Deleted at`,
|
|
description: msg`Date when the record was deleted`,
|
|
icon: 'IconCalendarMinus',
|
|
settings: {
|
|
displayFormat: DateDisplayFormat.RELATIVE,
|
|
},
|
|
})
|
|
@WorkspaceIsNullable()
|
|
deletedAt: string | null;
|
|
}
|