mirror of
https://github.com/twentyhq/twenty.git
synced 2025-01-06 03:45:15 +03:00
Fix relation field type (#4992)
This commit is contained in:
parent
cf50391b00
commit
64cc6ecc3b
@ -23,8 +23,8 @@ export const getOptionValueFromLabel = (label: string) => {
|
||||
export const formatFieldMetadataItemInput = (
|
||||
input: Pick<
|
||||
Field,
|
||||
'label' | 'icon' | 'description' | 'defaultValue' | 'type' | 'options'
|
||||
>,
|
||||
'label' | 'icon' | 'description' | 'defaultValue' | 'options'
|
||||
> & { type?: FieldMetadataType },
|
||||
) => {
|
||||
const options = input.options as FieldMetadataOption[];
|
||||
let defaultValue = input.defaultValue;
|
||||
|
@ -12,7 +12,7 @@ export type FormatRelationMetadataInputParams = {
|
||||
field: Pick<Field, 'label' | 'icon' | 'description' | 'type'>;
|
||||
objectMetadataId: string;
|
||||
connect: {
|
||||
field: Pick<Field, 'label' | 'icon' | 'type'>;
|
||||
field: Pick<Field, 'label' | 'icon'>;
|
||||
objectMetadataId: string;
|
||||
};
|
||||
};
|
||||
|
@ -36,6 +36,12 @@ export const fieldMetadataFormDefaultValues: FormValues = {
|
||||
select: [{ color: 'green', label: 'Option 1', value: v4() }],
|
||||
multiSelect: [{ color: 'green', label: 'Option 1', value: v4() }],
|
||||
};
|
||||
const relationTargetFieldSchema = z.object({
|
||||
description: z.string().optional(),
|
||||
icon: z.string().startsWith('Icon'),
|
||||
label: z.string().min(1),
|
||||
defaultValue: z.any(),
|
||||
});
|
||||
const fieldSchema = z.object({
|
||||
description: z.string().optional(),
|
||||
icon: z.string().startsWith('Icon'),
|
||||
@ -62,7 +68,7 @@ const relationSchema = fieldSchema.merge(
|
||||
z.object({
|
||||
type: z.literal(FieldMetadataType.Relation),
|
||||
relation: z.object({
|
||||
field: fieldSchema,
|
||||
field: relationTargetFieldSchema,
|
||||
objectMetadataId: z.string().uuid(),
|
||||
type: z.enum([
|
||||
RelationMetadataType.OneToMany,
|
||||
|
@ -141,7 +141,6 @@ export const SettingsObjectNewFieldStep2 = () => {
|
||||
field: {
|
||||
icon: validatedFormValues.relation.field.icon,
|
||||
label: validatedFormValues.relation.field.label,
|
||||
type: validatedFormValues.relation.field.type,
|
||||
},
|
||||
objectMetadataId: validatedFormValues.relation.objectMetadataId,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user