/
dimamir
/
undb
Обзор
Документация
Войти
/
dimamir
/
undb
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/table/src/methods/create-form.method.ts
27 строк
944 B
nichenqin
feat: navigate to new form after create form
19 сен 2024, 06:18
19 сен 2024, 06:18
66b0528
Код
Авторство
О чём код?
import { applyRules, Some, type Option } from "@undb/domain" import { FormVO, type ICreateFormDTO } from "../modules" import { FormNameShouldBeUnique } from "../rules/form-name-should-be-unique.rule" import type { TableComositeSpecification } from "../specifications" import { WithNewFormSpecification } from "../specifications/table-forms.specification" import type { TableDo } from "../table.do" export function createFormMethod( this: TableDo, dto: ICreateFormDTO, ): { spec: Option<TableComositeSpecification>; form: FormVO } { const form = FormVO.create(this, dto) const spec = new WithNewFormSpecification(form) spec.mutate(this) const names = this.forms?.forms.map((f) => f.name) ?? [] applyRules(new FormNameShouldBeUnique(names)) // const event = new FormCreatedEvent({ // tableId: this.id.value, // field: spec.field.toJSON(), // }) // this.addDomainEvent(event) return { spec: Some(spec), form } }