Browse Source

fix: insert row undo part

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5332/head
mertmit 2 years ago
parent
commit
1b9c9fa6ce
  1. 14
      packages/nc-gui/composables/useViewData.ts

14
packages/nc-gui/composables/useViewData.ts

@ -260,6 +260,12 @@ export function useViewData(
)
if (!undo) {
Object.assign(currentRow, {
row: { ...insertedData, ...row },
rowMeta: { ...(currentRow.rowMeta || {}), new: undefined },
oldRow: { ...insertedData },
})
const id = extractPkFromRow(insertedData, metaValue?.columns as ColumnType[])
const pkData = rowPkData(insertedData, metaValue?.columns as ColumnType[])
const rowIndex = findIndexByPk(pkData)
@ -297,20 +303,12 @@ export function useViewData(
undo: {
fn: async function undo(this: UndoRedoAction, id: string) {
await deleteRowById(id)
const pk: Record<string, string> = rowPkData(row.row, meta?.value?.columns as ColumnType[])
const rowIndex = findIndexByPk(pk)
if (rowIndex) formattedData.value.splice(rowIndex, 1)
},
args: [id],
},
scope: defineViewScope({ view: viewMeta.value }),
})
Object.assign(currentRow, {
row: { ...insertedData, ...row },
rowMeta: { ...(currentRow.rowMeta || {}), new: undefined },
oldRow: { ...insertedData },
})
}
await syncCount()

Loading…
Cancel
Save