Date field format display (#11384)
## 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>
This commit is contained in:
@ -13,6 +13,12 @@ export type FieldMetadataDefaultSettings = {
|
||||
isForeignKey?: boolean;
|
||||
};
|
||||
|
||||
export enum DateDisplayFormat {
|
||||
RELATIVE = 'RELATIVE',
|
||||
USER_SETTINGS = 'USER_SETTINGS',
|
||||
CUSTOM = 'CUSTOM',
|
||||
}
|
||||
|
||||
export type FieldNumberVariant = 'number' | 'percentage';
|
||||
|
||||
export type FieldMetadataNumberSettings = {
|
||||
@ -26,11 +32,11 @@ export type FieldMetadataTextSettings = {
|
||||
};
|
||||
|
||||
export type FieldMetadataDateSettings = {
|
||||
displayAsRelativeDate?: boolean;
|
||||
displayFormat?: DateDisplayFormat;
|
||||
};
|
||||
|
||||
export type FieldMetadataDateTimeSettings = {
|
||||
displayAsRelativeDate?: boolean;
|
||||
displayFormat?: DateDisplayFormat;
|
||||
};
|
||||
|
||||
export type FieldMetadataRelationSettings = {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
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';
|
||||
@ -28,7 +30,7 @@ export abstract class BaseWorkspaceEntity {
|
||||
icon: 'IconCalendar',
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayAsRelativeDate: true,
|
||||
displayFormat: DateDisplayFormat.RELATIVE,
|
||||
},
|
||||
})
|
||||
createdAt: string;
|
||||
@ -41,7 +43,7 @@ export abstract class BaseWorkspaceEntity {
|
||||
icon: 'IconCalendarClock',
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayAsRelativeDate: true,
|
||||
displayFormat: DateDisplayFormat.RELATIVE,
|
||||
},
|
||||
})
|
||||
updatedAt: string;
|
||||
@ -53,7 +55,7 @@ export abstract class BaseWorkspaceEntity {
|
||||
description: msg`Date when the record was deleted`,
|
||||
icon: 'IconCalendarMinus',
|
||||
settings: {
|
||||
displayAsRelativeDate: true,
|
||||
displayFormat: DateDisplayFormat.RELATIVE,
|
||||
},
|
||||
})
|
||||
@WorkspaceIsNullable()
|
||||
|
||||
Reference in New Issue
Block a user