mirror of
https://github.com/twentyhq/twenty.git
synced 2025-01-07 17:28:47 +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 = (
|
export const formatFieldMetadataItemInput = (
|
||||||
input: Pick<
|
input: Pick<
|
||||||
Field,
|
Field,
|
||||||
'label' | 'icon' | 'description' | 'defaultValue' | 'type' | 'options'
|
'label' | 'icon' | 'description' | 'defaultValue' | 'options'
|
||||||
>,
|
> & { type?: FieldMetadataType },
|
||||||
) => {
|
) => {
|
||||||
const options = input.options as FieldMetadataOption[];
|
const options = input.options as FieldMetadataOption[];
|
||||||
let defaultValue = input.defaultValue;
|
let defaultValue = input.defaultValue;
|
||||||
|
@ -12,7 +12,7 @@ export type FormatRelationMetadataInputParams = {
|
|||||||
field: Pick<Field, 'label' | 'icon' | 'description' | 'type'>;
|
field: Pick<Field, 'label' | 'icon' | 'description' | 'type'>;
|
||||||
objectMetadataId: string;
|
objectMetadataId: string;
|
||||||
connect: {
|
connect: {
|
||||||
field: Pick<Field, 'label' | 'icon' | 'type'>;
|
field: Pick<Field, 'label' | 'icon'>;
|
||||||
objectMetadataId: string;
|
objectMetadataId: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -36,6 +36,12 @@ export const fieldMetadataFormDefaultValues: FormValues = {
|
|||||||
select: [{ color: 'green', label: 'Option 1', value: v4() }],
|
select: [{ color: 'green', label: 'Option 1', value: v4() }],
|
||||||
multiSelect: [{ 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({
|
const fieldSchema = z.object({
|
||||||
description: z.string().optional(),
|
description: z.string().optional(),
|
||||||
icon: z.string().startsWith('Icon'),
|
icon: z.string().startsWith('Icon'),
|
||||||
@ -62,7 +68,7 @@ const relationSchema = fieldSchema.merge(
|
|||||||
z.object({
|
z.object({
|
||||||
type: z.literal(FieldMetadataType.Relation),
|
type: z.literal(FieldMetadataType.Relation),
|
||||||
relation: z.object({
|
relation: z.object({
|
||||||
field: fieldSchema,
|
field: relationTargetFieldSchema,
|
||||||
objectMetadataId: z.string().uuid(),
|
objectMetadataId: z.string().uuid(),
|
||||||
type: z.enum([
|
type: z.enum([
|
||||||
RelationMetadataType.OneToMany,
|
RelationMetadataType.OneToMany,
|
||||||
|
@ -141,7 +141,6 @@ export const SettingsObjectNewFieldStep2 = () => {
|
|||||||
field: {
|
field: {
|
||||||
icon: validatedFormValues.relation.field.icon,
|
icon: validatedFormValues.relation.field.icon,
|
||||||
label: validatedFormValues.relation.field.label,
|
label: validatedFormValues.relation.field.label,
|
||||||
type: validatedFormValues.relation.field.type,
|
|
||||||
},
|
},
|
||||||
objectMetadataId: validatedFormValues.relation.objectMetadataId,
|
objectMetadataId: validatedFormValues.relation.objectMetadataId,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user