feat: add Relation field form (#2572)

* feat: add useCreateOneRelationMetadata and useRelationMetadata

Closes #2423

* feat: add Relation field form

Closes #2003

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Thaïs
2023-11-17 23:38:39 +01:00
committed by GitHub
parent fea0bbeb2a
commit 18dac1a2b6
34 changed files with 1285 additions and 643 deletions

View File

@ -7,7 +7,7 @@ import {
IconMail,
IconNumbers,
IconPhone,
IconPlug,
IconRelationManyToMany,
IconTag,
IconTextSize,
IconUser,
@ -61,9 +61,12 @@ export const dataTypes: Record<
[FieldMetadataType.Currency]: {
label: 'Currency',
Icon: IconCoins,
defaultValue: { amount: 2000, currency: CurrencyCode.Usd },
defaultValue: { amountMicros: 2000000000, currencyCode: CurrencyCode.Usd },
},
[FieldMetadataType.Relation]: {
label: 'Relation',
Icon: IconRelationManyToMany,
},
[FieldMetadataType.Relation]: { label: 'Relation', Icon: IconPlug },
[FieldMetadataType.Email]: { label: 'Email', Icon: IconMail },
[FieldMetadataType.Phone]: { label: 'Phone', Icon: IconPhone },
[FieldMetadataType.Probability]: {

View File

@ -0,0 +1,34 @@
import { IconRelationOneToMany, IconRelationOneToOne } from '@/ui/display/icon';
import { IconComponent } from '@/ui/display/icon/types/IconComponent';
import { RelationMetadataType } from '~/generated-metadata/graphql';
import OneToManySvg from '../assets/OneToMany.svg';
import OneToOneSvg from '../assets/OneToOne.svg';
import { RelationType } from '../types/RelationType';
export const relationTypes: Record<
RelationType,
{
label: string;
Icon: IconComponent;
imageSrc: string;
isImageFlipped?: boolean;
}
> = {
[RelationMetadataType.OneToMany]: {
label: 'Has many',
Icon: IconRelationOneToMany,
imageSrc: OneToManySvg,
},
[RelationMetadataType.OneToOne]: {
label: 'Has one',
Icon: IconRelationOneToOne,
imageSrc: OneToOneSvg,
},
MANY_TO_ONE: {
label: 'Belongs to one',
Icon: IconRelationOneToMany,
imageSrc: OneToManySvg,
isImageFlipped: true,
},
};