form builder module

This commit is contained in:
2026-01-28 14:59:25 +03:30
parent e44a239ef0
commit 8121b27248
27 changed files with 151 additions and 129 deletions
@@ -0,0 +1,37 @@
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { FieldOption } from './field-option.entity';
import { FieldType } from '../interface/print';
import { Section } from 'src/modules/print/entities/section.entity';
import { BaseEntity } from 'src/common/entities/base.entity';
import { Product } from 'src/modules/product/entities/product.entity';
@Entity({ tableName: 'field' })
export class Field extends BaseEntity {
@PrimaryKey({ type: 'bigint', autoincrement: true })
id: bigint
@OneToMany(() => FieldOption, (attrValue) => attrValue.field)
options = new Collection<FieldOption>(this)
@ManyToOne(() => Section, { nullable: true })
section?: Section
@ManyToOne(() => Product, { nullable: true })
product?: Product
@Property()
name: string;
@Enum(() => FieldType)
type: FieldType;
@Property({ type: 'boolean', default: false })
isRequired: boolean = false;
@Property({ type: 'boolean', default: false })
multiple: boolean = false;
@Property({ type: 'int', nullable: true })
order?: number;
}