Skip to content

Commit

Permalink
fix: fix create from template
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Aug 18, 2024
1 parent 7b699f1 commit 755f57f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class CreateFromTemplateCommandHandler implements ICommandHandler<CreateF
}

const targetSpaceId = command.targetSpaceId ?? mustGetCurrentSpaceId()
const duplicatedBase = await this.tableService.duplicateBase(base, targetSpaceId, {
const duplicatedBase = await this.tableService.duplicateBase(base, command.spaceId, targetSpaceId, {
id: command.baseId,
name: command.name,
includeData: command.includeData,
Expand Down
4 changes: 2 additions & 2 deletions packages/persistence/src/table/table.filter-visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ export class TableFilterVisitor extends AbstractQBVisitor<TableDo> implements IT
constructor(
private readonly qb: IQueryBuilder,
protected readonly eb: ExpressionBuilder<Database, "undb_table" | "undb_table_id_mapping">,
ignoreSapce = false,
ignoreSpace = false,
) {
super(eb)
if (!ignoreSapce) {
if (!ignoreSpace) {
const spaceId = mustGetCurrentSpaceId()
this.addCond(this.eb.eb("undb_table.space_id", "=", spaceId))
}
Expand Down
3 changes: 2 additions & 1 deletion packages/table/src/services/methods/duplicate-base.method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { TableService } from "../table.service"
export async function duplicateBaseMethod(
this: TableService,
base: Base,
spaceId: ISpaceId,
targetSpaceId: ISpaceId,
dto: IDuplicateBaseDTO,
) {
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -26,7 +26,7 @@ export async function duplicateTablesMethod(
{
tableId: idsMap.get(table.id.value)!,
baseId: base.id.value,
spaceId,
spaceId: targetSpaceId,
includeData,
},
[],
Expand Down
2 changes: 1 addition & 1 deletion packages/table/src/services/table.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface ITableService {
createTableView(dto: ICreateTableViewDTO): Promise<TableDo>

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

Expand Down

0 comments on commit 755f57f

Please sign in to comment.