Browse Source

fix: kanban undo/redo card insert

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5332/head
mertmit 2 years ago
parent
commit
2de2a2852f
  1. 21
      packages/nc-gui/composables/useExpandedFormStore.ts
  2. 12
      packages/nc-gui/composables/useKanbanViewStore.ts

21
packages/nc-gui/composables/useExpandedFormStore.ts

@ -160,23 +160,28 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
data = await $api.dbTableRow.create('noco', project.value.title as string, meta.value.title, insertObj)
Object.assign(row.value, {
row: data,
rowMeta: {},
oldRow: { ...data },
})
if (!undo) {
const id = extractPkFromRow(data, meta.value?.columns as ColumnType[])
const pkData = rowPkData(row.value.row, meta.value?.columns as ColumnType[])
// TODO remove linked record
addUndo({
redo: {
fn: async function redo(this: UndoRedoAction, row: Row) {
const pkData = rowPkData(row.row, meta.value?.columns as ColumnType[])
row.row = { ...pkData, ...row.row }
await $api.dbTableRow.create('noco', project.value.title as string, meta.value.title, row.row)
fn: async function redo(this: UndoRedoAction, rowData: any) {
await $api.dbTableRow.create('noco', project.value.title as string, meta.value.title, { ...pkData, ...rowData })
if (activeView.value?.type === ViewTypes.KANBAN) {
const { loadKanbanData } = useKanbanViewStoreOrThrow()
await loadKanbanData()
}
reloadTrigger?.trigger()
},
args: [clone(row.value)],
args: [clone(insertObj)],
},
undo: {
fn: async function undo(this: UndoRedoAction, id: string) {
@ -201,12 +206,6 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
scope: defineViewScope({ view: activeView.value }),
})
}
Object.assign(row.value, {
row: data,
rowMeta: {},
oldRow: { ...data },
})
} else {
const updateOrInsertObj = [...changedColumns.value].reduce((obj, col) => {
obj[col] = row.value.row[col]

12
packages/nc-gui/composables/useKanbanViewStore.ts

@ -369,14 +369,14 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState(
},
scope: defineViewScope({ view: viewMeta.value as ViewType }),
})
formattedData.value.get(null)?.splice(rowIndex ?? 0, 1, {
row: insertedData,
rowMeta: {},
oldRow: { ...insertedData },
})
}
formattedData.value.get(null)?.splice(rowIndex ?? 0, 1, {
row: insertedData,
rowMeta: {},
oldRow: { ...insertedData },
})
return insertedData
} catch (error: any) {
message.error(await extractSdkResponseErrorMsg(error))

Loading…
Cancel
Save