Add label identifier to object decorator (#6227)
## Context LabelIdentifier and ImageIdentifier are metadata info attached to objectMetadata that are used to display a record in a more readable way. Those columns point to existing fields that are part of the object. For example, for a relation picker of a person, we will show a record using the "name" labelIdentifier and the "avatarUrl" imageIdentifier. <img width="215" alt="Screenshot 2024-07-11 at 18 45 51" src="https://github.com/twentyhq/twenty/assets/1834158/488f8294-0d7c-4209-b763-2499716ef29d"> Currently, the FE has a specific logic for company and people objects and we have a way to update this value via the API for custom objects, but the code is not flexible enough to change other standard objects. This PR updates the WorkspaceEntity API so we can now provide the labelIdentifier and imageIdentifier in the WorkspaceEntity decorator. Example: ```typescript @WorkspaceEntity({ standardId: STANDARD_OBJECT_IDS.activity, namePlural: 'activities', labelSingular: 'Activity', labelPlural: 'Activities', description: 'An activity', icon: 'IconCheckbox', labelIdentifierStandardId: ACTIVITY_STANDARD_FIELD_IDS.title, }) @WorkspaceIsSystem() export class ActivityWorkspaceEntity extends BaseWorkspaceEntity { @WorkspaceField({ standardId: ACTIVITY_STANDARD_FIELD_IDS.title, type: FieldMetadataType.TEXT, label: 'Title', description: 'Activity title', icon: 'IconNotes', }) title: string; ... ```
This commit is contained in:
@ -0,0 +1,23 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class FixIdentifierTypes1721057142509 implements MigrationInterface {
|
||||
name = 'FixIdentifierTypes1721057142509';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."objectMetadata" ALTER COLUMN "labelIdentifierFieldMetadataId" TYPE uuid USING "labelIdentifierFieldMetadataId"::uuid`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."objectMetadata" ALTER COLUMN "imageIdentifierFieldMetadataId" TYPE uuid USING "imageIdentifierFieldMetadataId"::uuid`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."objectMetadata" ALTER COLUMN "labelIdentifierFieldMetadataId" TYPE text USING "labelIdentifierFieldMetadataId"::text`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."objectMetadata" ALTER COLUMN "imageIdentifierFieldMetadataId" TYPE text USING "imageIdentifierFieldMetadataId"::text`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user