-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: navigate to new form after create form
- Loading branch information
Showing
7 changed files
with
37 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 10 additions & 5 deletions
15
packages/command-handlers/src/handlers/create-table-form.command-handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
import { CreateTableFormCommand } from "@undb/commands" | ||
import { CreateTableFormCommand, type ICreateTableFormCommandOutput } from "@undb/commands" | ||
import { commandHandler } from "@undb/cqrs" | ||
import { singleton } from "@undb/di" | ||
import type { ICommandHandler } from "@undb/domain" | ||
import { injectTableService, type ITableService } from "@undb/table" | ||
|
||
@commandHandler(CreateTableFormCommand) | ||
@singleton() | ||
export class CreateTableFormCommandHandler implements ICommandHandler<CreateTableFormCommand, any> { | ||
export class CreateTableFormCommandHandler | ||
implements ICommandHandler<CreateTableFormCommand, ICreateTableFormCommandOutput> | ||
{ | ||
constructor( | ||
@injectTableService() | ||
private readonly service: ITableService, | ||
) {} | ||
|
||
async execute(command: CreateTableFormCommand): Promise<any> { | ||
const table = await this.service.createTableForm(command.input) | ||
async execute(command: CreateTableFormCommand): Promise<ICreateTableFormCommandOutput> { | ||
const { table, form } = await this.service.createTableForm(command.input) | ||
|
||
return table.id.value | ||
return { | ||
tableId: table.id.value, | ||
formId: form.id, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
packages/table/src/services/methods/create-table-form.method.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import type { FormVO } from "../../modules" | ||
import type { ICreateTableFormDTO } from "../../modules/forms/dto/create-form.dto" | ||
import { TableIdVo } from "../../table-id.vo" | ||
import type { TableDo } from "../../table.do" | ||
import type { TableService } from "../table.service" | ||
|
||
export async function createTableFormMethod(this: TableService, dto: ICreateTableFormDTO): Promise<TableDo> { | ||
export async function createTableFormMethod( | ||
this: TableService, | ||
dto: ICreateTableFormDTO, | ||
): Promise<{ table: TableDo; form: FormVO }> { | ||
const table = (await this.repository.findOneById(new TableIdVo(dto.tableId))).expect("Not found table") | ||
|
||
const spec = table.$createForm(dto) | ||
const { spec, form } = table.$createForm(dto) | ||
|
||
await this.repository.updateOneById(table, spec) | ||
|
||
return table | ||
return { table, form } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters