The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Create Relation with Fields from both sides (#2480)
Weiko3de2fc72dcdd
diff --git a/front/src/generated-metadata/graphql.ts b/front/src/generated-metadata/graphql.tsindex 6de2fb64ee1..f9dae4c69be 100644--- a/front/src/generated-metadata/graphql.ts+++ b/front/src/generated-metadata/graphql.ts@@ -203,11 +203,14 @@ export type CreateOneRelationInput = {export type CreateRelationInput = {description?: InputMaybe<Scalars['String']['input']>;+ fromIcon?: InputMaybe<Scalars['String']['input']>;+ fromLabel: Scalars['String']['input'];+ fromName: Scalars['String']['input'];fromObjectMetadataId: Scalars['String']['input'];- icon?: InputMaybe<Scalars['String']['input']>;- label: Scalars['String']['input'];- name: Scalars['String']['input'];relationType: Scalars['String']['input'];+ toIcon?: InputMaybe<Scalars['String']['input']>;+ toLabel: Scalars['String']['input'];+ toName: Scalars['String']['input'];toObjectMetadataId: Scalars['String']['input'];};diff --git a/server/src/metadata/relation-metadata/dtos/create-relation.input.ts b/server/src/metadata/relation-metadata/dtos/create-relation.input.tsindex 80eda1564fc..f48b972e9e9 100644--- a/server/src/metadata/relation-metadata/dtos/create-relation.input.ts+++ b/server/src/metadata/relation-metadata/dtos/create-relation.input.ts@@ -33,22 +33,37 @@ export class CreateRelationInput {@IsString()@IsNotEmpty()@Field()- name: string;+ fromName: string;@IsString()@IsNotEmpty()@Field()- label: string;+ toName: string;++ @IsString()+ @IsNotEmpty()+ @Field()+ fromLabel: string;++ @IsString()+ @IsNotEmpty()+ @Field()+ toLabel: string;@IsString()@IsOptional()@Field({ nullable: true })- description?: string;+ fromIcon?: string;@IsString()@IsOptional()@Field({ nullable: true })- icon?: string;+ toIcon?: string;++ @IsString()+ @IsOptional()+ @Field({ nullable: true })+ description?: string;@HideField()workspaceId: string;diff --git a/server/src/metadata/relation-metadata/relation-metadata.service.ts b/server/src/metadata/relation-metadata/relation-metadata.service.tsindex 0ef71eb2069..0c0ea06cd30 100644--- a/server/src/metadata/relation-metadata/relation-metadata.service.ts+++ b/server/src/metadata/relation-metadata/relation-metadata.service.ts@@ -64,11 +64,12 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat}const createdFields = await this.fieldMetadataService.createMany([+ // FROM{- name: record.name,- label: record.label,+ name: record.fromName,+ label: record.fromLabel,description: record.description,- icon: record.icon,+ icon: record.fromIcon,isCustom: true,targetColumnMap: {},isActive: true,@@ -76,14 +77,12 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadatobjectMetadataId: record.fromObjectMetadataId,workspaceId: record.workspaceId,},- // NOTE: Since we have to create the field-metadata for the user, we need to use the toObjectMetadata info.- // This is not ideal because we might see some conflicts with existing names.- // NOTE2: Once MANY_TO_MANY is supported, we need to use namePlural/labelPlural instead.+ // TO{- name: objectMetadataMap[record.fromObjectMetadataId].nameSingular,- label: objectMetadataMap[record.fromObjectMetadataId].labelSingular,+ name: record.toName,+ label: record.toLabel,description: undefined,- icon: objectMetadataMap[record.fromObjectMetadataId].icon,+ icon: record.toIcon,isCustom: true,targetColumnMap: {},isActive: true,