Skip to content

Commit 755f57f

Browse files
committed
fix: fix create from template
1 parent 7b699f1 commit 755f57f

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

packages/command-handlers/src/handlers/create-from-template.command-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class CreateFromTemplateCommandHandler implements ICommandHandler<CreateF
3030
}
3131

3232
const targetSpaceId = command.targetSpaceId ?? mustGetCurrentSpaceId()
33-
const duplicatedBase = await this.tableService.duplicateBase(base, targetSpaceId, {
33+
const duplicatedBase = await this.tableService.duplicateBase(base, command.spaceId, targetSpaceId, {
3434
id: command.baseId,
3535
name: command.name,
3636
includeData: command.includeData,

packages/persistence/src/table/table.filter-visitor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export class TableFilterVisitor extends AbstractQBVisitor<TableDo> implements IT
4242
constructor(
4343
private readonly qb: IQueryBuilder,
4444
protected readonly eb: ExpressionBuilder<Database, "undb_table" | "undb_table_id_mapping">,
45-
ignoreSapce = false,
45+
ignoreSpace = false,
4646
) {
4747
super(eb)
48-
if (!ignoreSapce) {
48+
if (!ignoreSpace) {
4949
const spaceId = mustGetCurrentSpaceId()
5050
this.addCond(this.eb.eb("undb_table.space_id", "=", spaceId))
5151
}

packages/table/src/services/methods/duplicate-base.method.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { TableService } from "../table.service"
77
export async function duplicateBaseMethod(
88
this: TableService,
99
base: Base,
10+
spaceId: ISpaceId,
1011
targetSpaceId: ISpaceId,
1112
dto: IDuplicateBaseDTO,
1213
) {
@@ -21,7 +22,7 @@ export async function duplicateBaseMethod(
2122

2223
await this.baseRepository.insert(duplicatedBase)
2324

24-
const tableSpec = and(new TableBaseIdSpecification(base.id.value), new TableSpaceIdSpecification(targetSpaceId))
25+
const tableSpec = and(new TableBaseIdSpecification(base.id.value), new TableSpaceIdSpecification(spaceId))
2526
const tables = await this.repository.find(tableSpec, true)
2627
await this.duplicateTables(targetSpaceId, duplicatedBase, tables, dto.includeData)
2728

packages/table/src/services/methods/duplicate-tables.method.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { TableService } from "../table.service"
88

99
export async function duplicateTablesMethod(
1010
this: TableService,
11-
spaceId: ISpaceId,
11+
targetSpaceId: ISpaceId,
1212
base: Base,
1313
tables: TableDo[],
1414
includeData: boolean = false,
@@ -26,7 +26,7 @@ export async function duplicateTablesMethod(
2626
{
2727
tableId: idsMap.get(table.id.value)!,
2828
baseId: base.id.value,
29-
spaceId,
29+
spaceId: targetSpaceId,
3030
includeData,
3131
},
3232
[],

packages/table/src/services/table.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface ITableService {
5555
createTableView(dto: ICreateTableViewDTO): Promise<TableDo>
5656

5757
exportView(tableId: string, dto: IExportViewDTO): Promise<{ table: TableDo; records: IReadableRecordDTO[] }>
58-
duplicateBase(base: Base, spaceId: ISpaceId, dto: IDuplicateBaseDTO): Promise<Base>
58+
duplicateBase(base: Base, spaceId: ISpaceId, targetSpaceId: ISpaceId, dto: IDuplicateBaseDTO): Promise<Base>
5959
duplicateTables(spaceId: ISpaceId, base: Base, tables: TableDo[]): Promise<TableDo[]>
6060
}
6161

0 commit comments

Comments
 (0)