This PR was created by [GitStart](https://gitstart.com/) to address the requirements from this ticket: [TWNTY-5491](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-5491). This ticket was imported from: [TWNTY-5491](https://github.com/twentyhq/twenty/issues/5491) --- ### Description **How To Test:**\ 1. Reset db using `npx nx database:reset twenty-server` on this PR 1. Run both backend and frontend 2. Navigate to `settings/data-model/objects/ `page 3. Select a `Custom `object from the list or create a new `Custom `object 4. Navigate to custom object details page and click on edit button 5. Finally edit the object details. **Issues and bugs** The Typecheck is failing but we could not see this error locally There is a bug after updating the label of a custom object. View title is not updated till refreshing the page. We could not find a consistent way to update this, should we reload the page after editing an object? ### Demo <https://www.loom.com/share/64ecb57efad7498d99085cb11480b5dd?sid=28d0868c-e54f-454d-8432-3f789be9e2b7> ### Refs #5491 --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: gitstart-twenty <140154534+gitstart-twenty@users.noreply.github.com> Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu> Co-authored-by: Charles Bochet <charles@twenty.com> Co-authored-by: Weiko <corentin@twenty.com>
123 lines
3.1 KiB
TypeScript
123 lines
3.1 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
ManyToOne,
|
|
OneToMany,
|
|
PrimaryGeneratedColumn,
|
|
Relation,
|
|
Unique,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
|
|
import { ObjectMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/object-metadata.interface';
|
|
|
|
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
|
|
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
|
import { IndexMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-metadata.entity';
|
|
import { RelationMetadataEntity } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
|
|
|
@Entity('objectMetadata')
|
|
@Unique('IndexOnNameSingularAndWorkspaceIdUnique', [
|
|
'nameSingular',
|
|
'workspaceId',
|
|
])
|
|
@Unique('IndexOnNamePluralAndWorkspaceIdUnique', ['namePlural', 'workspaceId'])
|
|
export class ObjectMetadataEntity implements ObjectMetadataInterface {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ nullable: true, type: 'uuid' })
|
|
standardId: string | null;
|
|
|
|
@Column({ nullable: false, type: 'uuid' })
|
|
dataSourceId: string;
|
|
|
|
@Column({ nullable: false })
|
|
nameSingular: string;
|
|
|
|
@Column({ nullable: false })
|
|
namePlural: string;
|
|
|
|
@Column({ nullable: false })
|
|
labelSingular: string;
|
|
|
|
@Column({ nullable: false })
|
|
labelPlural: string;
|
|
|
|
@Column({ nullable: true, type: 'text' })
|
|
description: string;
|
|
|
|
@Column({ nullable: true })
|
|
icon: string;
|
|
|
|
@Column({ nullable: false })
|
|
targetTableName: string;
|
|
|
|
@Column({ default: false })
|
|
isCustom: boolean;
|
|
|
|
@Column({ default: false })
|
|
isRemote: boolean;
|
|
|
|
@Column({ default: false })
|
|
isActive: boolean;
|
|
|
|
@Column({ default: false })
|
|
isSystem: boolean;
|
|
|
|
@Column({ default: true })
|
|
isAuditLogged: boolean;
|
|
|
|
@Column({ nullable: true, type: 'uuid' })
|
|
labelIdentifierFieldMetadataId?: string | null;
|
|
|
|
@Column({ nullable: true, type: 'uuid' })
|
|
imageIdentifierFieldMetadataId?: string | null;
|
|
|
|
@Column({ default: true })
|
|
shouldSyncLabelAndName: boolean;
|
|
|
|
@Column({ nullable: false, type: 'uuid' })
|
|
workspaceId: string;
|
|
|
|
@OneToMany(() => FieldMetadataEntity, (field) => field.object, {
|
|
cascade: true,
|
|
})
|
|
fields: Relation<FieldMetadataEntity[]>;
|
|
|
|
@OneToMany(() => IndexMetadataEntity, (index) => index.objectMetadata, {
|
|
cascade: true,
|
|
})
|
|
indexMetadatas: Relation<IndexMetadataEntity[]>;
|
|
|
|
@OneToMany(
|
|
() => RelationMetadataEntity,
|
|
(relation: RelationMetadataEntity) => relation.fromObjectMetadata,
|
|
{
|
|
cascade: true,
|
|
},
|
|
)
|
|
fromRelations: Relation<RelationMetadataEntity[]>;
|
|
|
|
@OneToMany(
|
|
() => RelationMetadataEntity,
|
|
(relation: RelationMetadataEntity) => relation.toObjectMetadata,
|
|
{
|
|
cascade: true,
|
|
},
|
|
)
|
|
toRelations: Relation<RelationMetadataEntity[]>;
|
|
|
|
@ManyToOne(() => DataSourceEntity, (dataSource) => dataSource.objects, {
|
|
onDelete: 'CASCADE',
|
|
})
|
|
dataSource: Relation<DataSourceEntity>;
|
|
|
|
@CreateDateColumn({ type: 'timestamptz' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ type: 'timestamptz' })
|
|
updatedAt: Date;
|
|
}
|