|
|
@ -256,30 +256,22 @@ export function useViewData( |
|
|
|
|
|
|
|
|
|
|
|
addUndo({ |
|
|
|
addUndo({ |
|
|
|
redo: { |
|
|
|
redo: { |
|
|
|
fn: async function redo( |
|
|
|
fn: async function redo(this: UndoRedoAction, row: Row, ltarState: Record<string, any>) { |
|
|
|
this: UndoRedoAction, |
|
|
|
|
|
|
|
row: Row, |
|
|
|
|
|
|
|
ltarState: Record<string, any>, |
|
|
|
|
|
|
|
{ metaValue, viewMetaValue }: { metaValue?: TableType; viewMetaValue?: ViewType }, |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
const pkData = rowPkData(row.row, metaValue?.columns as ColumnType[]) |
|
|
|
const pkData = rowPkData(row.row, metaValue?.columns as ColumnType[]) |
|
|
|
row.row = { ...pkData, ...row.row } |
|
|
|
row.row = { ...pkData, ...row.row } |
|
|
|
await insertRow(row, ltarState, { metaValue, viewMetaValue }, true) |
|
|
|
await insertRow(row, ltarState, undefined, true) |
|
|
|
loadData() |
|
|
|
loadData() |
|
|
|
}, |
|
|
|
}, |
|
|
|
args: [clone(currentRow), clone(ltarState), clone({ metaValue, viewMetaValue })], |
|
|
|
args: [clone(currentRow), clone(ltarState)], |
|
|
|
}, |
|
|
|
}, |
|
|
|
undo: { |
|
|
|
undo: { |
|
|
|
fn: async function undo( |
|
|
|
fn: async function undo(this: UndoRedoAction, id: string) { |
|
|
|
this: UndoRedoAction, |
|
|
|
await deleteRowById(id) |
|
|
|
id: string, |
|
|
|
|
|
|
|
{ metaValue, viewMetaValue }: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
await deleteRowById(id, { metaValue, viewMetaValue }) |
|
|
|
|
|
|
|
loadData() |
|
|
|
loadData() |
|
|
|
}, |
|
|
|
}, |
|
|
|
args: [id, clone({ metaValue, viewMetaValue })], |
|
|
|
args: [id], |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
scope: viewMeta.value?.is_default ? [viewMeta.value.fk_model_id, viewMeta.value.title] : viewMeta.value?.title, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -338,30 +330,23 @@ export function useViewData( |
|
|
|
if (!undo) { |
|
|
|
if (!undo) { |
|
|
|
addUndo({ |
|
|
|
addUndo({ |
|
|
|
redo: { |
|
|
|
redo: { |
|
|
|
fn: async function redo( |
|
|
|
fn: async function redo(toUpdate: Row, property: string) { |
|
|
|
toUpdate: Row, |
|
|
|
await updateRowProperty(toUpdate, property, undefined, true) |
|
|
|
property: string, |
|
|
|
|
|
|
|
{ metaValue, viewMetaValue }: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
await updateRowProperty(toUpdate, property, { metaValue, viewMetaValue }, true) |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
args: [clone(toUpdate), property, clone({ metaValue, viewMetaValue })], |
|
|
|
args: [clone(toUpdate), property], |
|
|
|
}, |
|
|
|
}, |
|
|
|
undo: { |
|
|
|
undo: { |
|
|
|
fn: async function undo( |
|
|
|
fn: async function undo(toUpdate: Row, property: string) { |
|
|
|
toUpdate: Row, |
|
|
|
|
|
|
|
property: string, |
|
|
|
|
|
|
|
{ metaValue, viewMetaValue }: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
await updateRowProperty( |
|
|
|
await updateRowProperty( |
|
|
|
{ row: toUpdate.oldRow, oldRow: toUpdate.row, rowMeta: toUpdate.rowMeta }, |
|
|
|
{ row: toUpdate.oldRow, oldRow: toUpdate.row, rowMeta: toUpdate.rowMeta }, |
|
|
|
property, |
|
|
|
property, |
|
|
|
{ metaValue, viewMetaValue }, |
|
|
|
undefined, |
|
|
|
true, |
|
|
|
true, |
|
|
|
) |
|
|
|
) |
|
|
|
}, |
|
|
|
}, |
|
|
|
args: [clone(toUpdate), property, clone({ metaValue, viewMetaValue })], |
|
|
|
args: [clone(toUpdate), property], |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
scope: viewMeta.value?.is_default ? [viewMeta.value.fk_model_id, viewMeta.value.title] : viewMeta.value?.title, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
/** update row data(to sync formula and other related columns) |
|
|
|
/** update row data(to sync formula and other related columns) |
|
|
@ -461,34 +446,24 @@ export function useViewData( |
|
|
|
.join('___') |
|
|
|
.join('___') |
|
|
|
|
|
|
|
|
|
|
|
if (!undo) { |
|
|
|
if (!undo) { |
|
|
|
const metaValue = meta.value |
|
|
|
|
|
|
|
const viewMetaValue = viewMeta.value |
|
|
|
|
|
|
|
addUndo({ |
|
|
|
addUndo({ |
|
|
|
redo: { |
|
|
|
redo: { |
|
|
|
fn: async function undo( |
|
|
|
fn: async function undo(this: UndoRedoAction, id: string) { |
|
|
|
this: UndoRedoAction, |
|
|
|
await deleteRowById(id) |
|
|
|
id: string, |
|
|
|
|
|
|
|
{ metaValue, viewMetaValue }: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
await deleteRowById(id, { metaValue, viewMetaValue }) |
|
|
|
|
|
|
|
loadData() |
|
|
|
loadData() |
|
|
|
}, |
|
|
|
}, |
|
|
|
args: [id, clone({ metaValue, viewMetaValue })], |
|
|
|
args: [id], |
|
|
|
}, |
|
|
|
}, |
|
|
|
undo: { |
|
|
|
undo: { |
|
|
|
fn: async function redo( |
|
|
|
fn: async function redo(this: UndoRedoAction, row: Row, ltarState: Record<string, any>) { |
|
|
|
this: UndoRedoAction, |
|
|
|
const pkData = rowPkData(row.row, meta.value?.columns as ColumnType[]) |
|
|
|
row: Row, |
|
|
|
|
|
|
|
ltarState: Record<string, any>, |
|
|
|
|
|
|
|
{ metaValue, viewMetaValue }: { metaValue?: TableType; viewMetaValue?: ViewType }, |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
const pkData = rowPkData(row.row, metaValue?.columns as ColumnType[]) |
|
|
|
|
|
|
|
row.row = { ...pkData, ...row.row } |
|
|
|
row.row = { ...pkData, ...row.row } |
|
|
|
await insertRow(row, ltarState, { metaValue, viewMetaValue }, true) |
|
|
|
await insertRow(row, ltarState, {}, true) |
|
|
|
loadData() |
|
|
|
loadData() |
|
|
|
}, |
|
|
|
}, |
|
|
|
args: [clone(row), {}, clone({ metaValue, viewMetaValue })], |
|
|
|
args: [clone(row), {}], |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
scope: viewMeta.value?.is_default ? [viewMeta.value.fk_model_id, viewMeta.value.title] : viewMeta.value?.title, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|