Create Relation with Fields from both sides (#2480)
* Create relation with fields from both sides * update metadata codegen schema
This commit is contained in:
@ -33,23 +33,38 @@ 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 })
|
||||
fromIcon?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@Field({ nullable: true })
|
||||
toIcon?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@Field({ nullable: true })
|
||||
description?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@Field({ nullable: true })
|
||||
icon?: string;
|
||||
|
||||
@HideField()
|
||||
workspaceId: string;
|
||||
}
|
||||
|
||||
@ -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<RelationMetadat
|
||||
objectMetadataId: 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,
|
||||
|
||||
Reference in New Issue
Block a user