Create PageLayoutTab entity (#14104)

Closes https://github.com/twentyhq/core-team-issues/issues/1390
This commit is contained in:
Raphaël Bosi
2025-08-27 15:20:24 +02:00
committed by GitHub
parent a1fe1d7f47
commit 262ee457ef
4 changed files with 85 additions and 1 deletions
@@ -0,0 +1,45 @@
import {
Column,
CreateDateColumn,
DeleteDateColumn,
Entity,
Index,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
Relation,
UpdateDateColumn,
} from 'typeorm';
import { PageLayoutEntity } from 'src/engine/core-modules/page-layout/entities/page-layout.entity';
@Entity({ name: 'pageLayoutTab', schema: 'core' })
@Index('IDX_PAGE_LAYOUT_TAB_PAGE_LAYOUT_ID', ['pageLayoutId'])
export class PageLayoutTabEntity implements Required<PageLayoutTabEntity> {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ nullable: false })
title: string;
@Column({ nullable: false, type: 'int', default: 0 })
position: number;
@Column({ nullable: false, type: 'uuid' })
pageLayoutId: string;
@ManyToOne(() => PageLayoutEntity, {
onDelete: 'CASCADE',
})
@JoinColumn({ name: 'pageLayoutId' })
pageLayout: Relation<PageLayoutEntity>;
@CreateDateColumn({ type: 'timestamptz' })
createdAt: Date;
@UpdateDateColumn({ type: 'timestamptz' })
updatedAt: Date;
@DeleteDateColumn({ type: 'timestamptz' })
deletedAt: Date | null;
}
@@ -6,11 +6,13 @@ import {
Index,
JoinColumn,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
Relation,
UpdateDateColumn,
} from 'typeorm';
import { PageLayoutTabEntity } from 'src/engine/core-modules/page-layout/entities/page-layout-tab.entity';
import { PageLayoutType } from 'src/engine/core-modules/page-layout/enums/page-layout-type.enum';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
@@ -54,6 +56,11 @@ export class PageLayoutEntity implements Required<PageLayoutEntity> {
@JoinColumn({ name: 'objectMetadataId' })
objectMetadata: Relation<ObjectMetadataEntity> | null;
@OneToMany(() => PageLayoutTabEntity, (tab) => tab.pageLayout, {
cascade: true,
})
tabs: Relation<PageLayoutTabEntity[]>;
@CreateDateColumn({ type: 'timestamptz' })
createdAt: Date;
@@ -1,10 +1,13 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { PageLayoutTabEntity } from 'src/engine/core-modules/page-layout/entities/page-layout-tab.entity';
import { PageLayoutEntity } from 'src/engine/core-modules/page-layout/entities/page-layout.entity';
@Module({
imports: [TypeOrmModule.forFeature([PageLayoutEntity], 'core')],
imports: [
TypeOrmModule.forFeature([PageLayoutEntity, PageLayoutTabEntity], 'core'),
],
exports: [],
})
export class PageLayoutModule {}