form builder module
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user