From 755f57fb2bac383a263dc16652d011b409717351 Mon Sep 17 00:00:00 2001 From: nichenqin Date: Sun, 18 Aug 2024 22:47:03 +0800 Subject: [PATCH] fix: fix create from template --- .../src/handlers/create-from-template.command-handler.ts | 2 +- packages/persistence/src/table/table.filter-visitor.ts | 4 ++-- packages/table/src/services/methods/duplicate-base.method.ts | 3 ++- .../table/src/services/methods/duplicate-tables.method.ts | 4 ++-- packages/table/src/services/table.service.ts | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/command-handlers/src/handlers/create-from-template.command-handler.ts b/packages/command-handlers/src/handlers/create-from-template.command-handler.ts index af6c6ea9a..82277edd4 100644 --- a/packages/command-handlers/src/handlers/create-from-template.command-handler.ts +++ b/packages/command-handlers/src/handlers/create-from-template.command-handler.ts @@ -30,7 +30,7 @@ export class CreateFromTemplateCommandHandler implements ICommandHandler implements IT constructor( private readonly qb: IQueryBuilder, protected readonly eb: ExpressionBuilder, - ignoreSapce = false, + ignoreSpace = false, ) { super(eb) - if (!ignoreSapce) { + if (!ignoreSpace) { const spaceId = mustGetCurrentSpaceId() this.addCond(this.eb.eb("undb_table.space_id", "=", spaceId)) } diff --git a/packages/table/src/services/methods/duplicate-base.method.ts b/packages/table/src/services/methods/duplicate-base.method.ts index 51cd47ff4..97aee80b9 100644 --- a/packages/table/src/services/methods/duplicate-base.method.ts +++ b/packages/table/src/services/methods/duplicate-base.method.ts @@ -7,6 +7,7 @@ import type { TableService } from "../table.service" export async function duplicateBaseMethod( this: TableService, base: Base, + spaceId: ISpaceId, targetSpaceId: ISpaceId, dto: IDuplicateBaseDTO, ) { @@ -21,7 +22,7 @@ export async function duplicateBaseMethod( await this.baseRepository.insert(duplicatedBase) - const tableSpec = and(new TableBaseIdSpecification(base.id.value), new TableSpaceIdSpecification(targetSpaceId)) + const tableSpec = and(new TableBaseIdSpecification(base.id.value), new TableSpaceIdSpecification(spaceId)) const tables = await this.repository.find(tableSpec, true) await this.duplicateTables(targetSpaceId, duplicatedBase, tables, dto.includeData) diff --git a/packages/table/src/services/methods/duplicate-tables.method.ts b/packages/table/src/services/methods/duplicate-tables.method.ts index c4e14ac43..081fdc985 100644 --- a/packages/table/src/services/methods/duplicate-tables.method.ts +++ b/packages/table/src/services/methods/duplicate-tables.method.ts @@ -8,7 +8,7 @@ import type { TableService } from "../table.service" export async function duplicateTablesMethod( this: TableService, - spaceId: ISpaceId, + targetSpaceId: ISpaceId, base: Base, tables: TableDo[], includeData: boolean = false, @@ -26,7 +26,7 @@ export async function duplicateTablesMethod( { tableId: idsMap.get(table.id.value)!, baseId: base.id.value, - spaceId, + spaceId: targetSpaceId, includeData, }, [], diff --git a/packages/table/src/services/table.service.ts b/packages/table/src/services/table.service.ts index 511123495..79b56c368 100644 --- a/packages/table/src/services/table.service.ts +++ b/packages/table/src/services/table.service.ts @@ -55,7 +55,7 @@ export interface ITableService { createTableView(dto: ICreateTableViewDTO): Promise exportView(tableId: string, dto: IExportViewDTO): Promise<{ table: TableDo; records: IReadableRecordDTO[] }> - duplicateBase(base: Base, spaceId: ISpaceId, dto: IDuplicateBaseDTO): Promise + duplicateBase(base: Base, spaceId: ISpaceId, targetSpaceId: ISpaceId, dto: IDuplicateBaseDTO): Promise duplicateTables(spaceId: ISpaceId, base: Base, tables: TableDo[]): Promise }