323e66433e
Most changes are `implements` being unwrapped this is not a oxfmt regression Prettier in 3.7 (we're on 3.1) changed this behaviour prettier blog [post](https://prettier.io/blog/2025/11/27/3.7.0#change-18094) This unifies our linting tooling --------- Co-authored-by: github-actions <github-actions@twenty.com> Co-authored-by: Charles Bochet <charles@twenty.com>
112 lines
3.5 KiB
TypeScript
112 lines
3.5 KiB
TypeScript
import { ObjectType } from '@nestjs/graphql';
|
|
|
|
import {
|
|
PageLayoutWidgetConditionalDisplay,
|
|
PageLayoutWidgetPosition,
|
|
type GridPosition,
|
|
type SerializedRelation,
|
|
} from 'twenty-shared/types';
|
|
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
DeleteDateColumn,
|
|
Entity,
|
|
Index,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
type Relation,
|
|
} from 'typeorm';
|
|
|
|
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
|
import { PageLayoutTabEntity } from 'src/engine/metadata-modules/page-layout-tab/entities/page-layout-tab.entity';
|
|
import { WidgetConfigurationType } from 'src/engine/metadata-modules/page-layout-widget/enums/widget-configuration-type.type';
|
|
import { WidgetType } from 'src/engine/metadata-modules/page-layout-widget/enums/widget-type.enum';
|
|
import { PageLayoutWidgetConfigurationTypeSettings } from 'src/engine/metadata-modules/page-layout-widget/types/page-layout-widget-configuration.type';
|
|
import { OverridableEntity } from 'src/engine/workspace-manager/types/overridable-entity';
|
|
import { type JsonbProperty } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/types/jsonb-property.type';
|
|
|
|
export type PageLayoutWidgetOverrides = {
|
|
title?: string;
|
|
position?: PageLayoutWidgetPosition | null;
|
|
conditionalDisplay?: PageLayoutWidgetConditionalDisplay | null;
|
|
conditionalAvailabilityExpression?: string | null;
|
|
pageLayoutTabId?: SerializedRelation;
|
|
};
|
|
|
|
@Entity({ name: 'pageLayoutWidget', schema: 'core' })
|
|
@ObjectType('PageLayoutWidget')
|
|
@Index(
|
|
'IDX_PAGE_LAYOUT_WIDGET_WORKSPACE_ID_PAGE_LAYOUT_TAB_ID',
|
|
['workspaceId', 'pageLayoutTabId'],
|
|
{ where: '"deletedAt" IS NULL' },
|
|
)
|
|
@Index('IDX_PAGE_LAYOUT_WIDGET_OBJECT_METADATA_ID', ['objectMetadataId'])
|
|
export class PageLayoutWidgetEntity<
|
|
TWidgetConfigurationType extends WidgetConfigurationType =
|
|
WidgetConfigurationType,
|
|
>
|
|
extends OverridableEntity<PageLayoutWidgetOverrides>
|
|
implements Required<PageLayoutWidgetEntity>
|
|
{
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ nullable: false, type: 'uuid' })
|
|
pageLayoutTabId: string;
|
|
|
|
@ManyToOne(() => PageLayoutTabEntity, {
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'pageLayoutTabId' })
|
|
pageLayoutTab: Relation<PageLayoutTabEntity>;
|
|
|
|
@Column({ nullable: false })
|
|
title: string;
|
|
|
|
@Column({
|
|
type: 'enum',
|
|
enum: Object.values(WidgetType),
|
|
nullable: false,
|
|
default: WidgetType.VIEW,
|
|
})
|
|
type: WidgetType;
|
|
|
|
@Column({ nullable: true, type: 'uuid' })
|
|
objectMetadataId: string | null;
|
|
|
|
@ManyToOne(() => ObjectMetadataEntity, {
|
|
onDelete: 'CASCADE',
|
|
nullable: true,
|
|
})
|
|
@JoinColumn({ name: 'objectMetadataId' })
|
|
objectMetadata: Relation<ObjectMetadataEntity> | null;
|
|
|
|
@Column({ type: 'jsonb', nullable: true })
|
|
conditionalDisplay: JsonbProperty<PageLayoutWidgetConditionalDisplay | null>;
|
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
conditionalAvailabilityExpression: string | null;
|
|
|
|
@Column({ type: 'jsonb', nullable: false })
|
|
gridPosition: JsonbProperty<GridPosition>;
|
|
|
|
@Column({ type: 'jsonb', nullable: true })
|
|
position: JsonbProperty<PageLayoutWidgetPosition | null>;
|
|
|
|
@Column({ type: 'jsonb', nullable: false })
|
|
configuration: JsonbProperty<
|
|
PageLayoutWidgetConfigurationTypeSettings<TWidgetConfigurationType>
|
|
>;
|
|
|
|
@CreateDateColumn({ type: 'timestamptz' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ type: 'timestamptz' })
|
|
updatedAt: Date;
|
|
|
|
@DeleteDateColumn({ type: 'timestamptz' })
|
|
deletedAt: Date | null;
|
|
}
|