feat: expose foreign key (#2505)
* fix: typo * feat: expose foreign key * fix: foreign key exposition * fix: be able to filter by foreign key * feat: add `isSystem` on field metadata * feat: update all seeds * fix: seed issues * fix: sync metadata generated files * fix: squash metadata migrations * Fix conflicts --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -8,6 +8,7 @@ import {
|
||||
|
||||
import {
|
||||
Authorize,
|
||||
FilterableField,
|
||||
IDField,
|
||||
QueryOptions,
|
||||
Relation,
|
||||
@ -29,7 +30,6 @@ registerEnumType(FieldMetadataType, {
|
||||
})
|
||||
@QueryOptions({
|
||||
defaultResultSize: 10,
|
||||
disableFilter: true,
|
||||
disableSort: true,
|
||||
maxResultsSize: 1000,
|
||||
})
|
||||
@ -61,12 +61,15 @@ export class FieldMetadataDTO {
|
||||
@Field({ nullable: true, deprecationReason: 'Use label name instead' })
|
||||
placeholder?: string;
|
||||
|
||||
@Field()
|
||||
@FilterableField()
|
||||
isCustom: boolean;
|
||||
|
||||
@Field()
|
||||
@FilterableField()
|
||||
isActive: boolean;
|
||||
|
||||
@FilterableField()
|
||||
isSystem: boolean;
|
||||
|
||||
@Field()
|
||||
isNullable: boolean;
|
||||
|
||||
|
||||
@ -77,6 +77,9 @@ export class FieldMetadataEntity implements FieldMetadataInterface {
|
||||
@Column({ default: false })
|
||||
isActive: boolean;
|
||||
|
||||
@Column({ default: false })
|
||||
isSystem: boolean;
|
||||
|
||||
@Column({ nullable: true, default: true })
|
||||
isNullable: boolean;
|
||||
|
||||
|
||||
@ -100,18 +100,33 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
|
||||
description: undefined,
|
||||
icon: record.toIcon,
|
||||
isCustom: true,
|
||||
targetColumnMap: {
|
||||
value: foreignKeyColumnName,
|
||||
},
|
||||
targetColumnMap: {},
|
||||
isActive: true,
|
||||
type: FieldMetadataType.RELATION,
|
||||
objectMetadataId: record.toObjectMetadataId,
|
||||
workspaceId: record.workspaceId,
|
||||
},
|
||||
// FOREIGN KEY
|
||||
{
|
||||
name: foreignKeyColumnName,
|
||||
label: `${record.toLabel} Foreign Key`,
|
||||
description: undefined,
|
||||
icon: undefined,
|
||||
isCustom: true,
|
||||
targetColumnMap: {},
|
||||
isActive: true,
|
||||
// Should not be visible on the front side
|
||||
isSystem: true,
|
||||
type: FieldMetadataType.UUID,
|
||||
objectMetadataId: record.toObjectMetadataId,
|
||||
workspaceId: record.workspaceId,
|
||||
},
|
||||
]);
|
||||
|
||||
const createdFieldMap = createdFields.reduce((acc, curr) => {
|
||||
acc[curr.objectMetadataId] = curr;
|
||||
const createdFieldMap = createdFields.reduce((acc, fieldMetadata) => {
|
||||
if (fieldMetadata.type === FieldMetadataType.RELATION) {
|
||||
acc[fieldMetadata.objectMetadataId] = fieldMetadata;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user