Files
twenty/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/view.object-metadata.ts
Charles Bochet 5287b7c4ab Add icon, position and key on View (#4413)
* Add view key field

* Update Prefill demo, seed dev, prefill new workspace
2024-03-11 17:00:19 +01:00

116 lines
3.5 KiB
TypeScript

import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-metadata.decorator';
import { RelationMetadata } from 'src/workspace/workspace-sync-metadata/decorators/relation-metadata.decorator';
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
import { ViewFieldObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view-field.object-metadata';
import { ViewFilterObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view-filter.object-metadata';
import { ViewSortObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view-sort.object-metadata';
@ObjectMetadata({
namePlural: 'views',
labelSingular: 'View',
labelPlural: 'Views',
description: '(System) Views',
icon: 'IconLayoutCollage',
})
@IsSystem()
export class ViewObjectMetadata extends BaseObjectMetadata {
@FieldMetadata({
type: FieldMetadataType.TEXT,
label: 'Name',
description: 'View name',
})
name: string;
@FieldMetadata({
type: FieldMetadataType.UUID,
label: 'Object Metadata Id',
description: 'View target object',
})
objectMetadataId: string;
@FieldMetadata({
type: FieldMetadataType.TEXT,
label: 'Type',
description: 'View type',
defaultValue: { value: 'table' },
})
type: string;
@FieldMetadata({
type: FieldMetadataType.SELECT,
label: 'Key',
description: 'View key',
options: [{ value: 'INDEX', label: 'Index', position: 0, color: 'red' }],
defaultValue: { value: 'INDEX' },
})
@IsNullable()
key: string;
@FieldMetadata({
type: FieldMetadataType.TEXT,
label: 'Icon',
description: 'View icon',
})
icon: string;
@FieldMetadata({
type: FieldMetadataType.POSITION,
label: 'Position',
description: 'View position',
})
@IsNullable()
position: number;
@FieldMetadata({
type: FieldMetadataType.BOOLEAN,
label: 'Compact View',
description: 'Describes if the view is in compact mode',
defaultValue: { value: false },
})
isCompact: boolean;
@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'View Fields',
description: 'View Fields',
icon: 'IconTag',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
inverseSideTarget: () => ViewFieldObjectMetadata,
})
@IsNullable()
viewFields: ViewFieldObjectMetadata[];
@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'View Filters',
description: 'View Filters',
icon: 'IconFilterBolt',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
inverseSideTarget: () => ViewFilterObjectMetadata,
})
@IsNullable()
viewFilters: ViewFilterObjectMetadata[];
@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'View Sorts',
description: 'View Sorts',
icon: 'IconArrowsSort',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
inverseSideTarget: () => ViewSortObjectMetadata,
})
@IsNullable()
viewSorts: ViewSortObjectMetadata[];
}