diff --git a/packages/nc-gui/components/smartsheet/Kanban.vue b/packages/nc-gui/components/smartsheet/Kanban.vue index a39e1b0688..2ce52b749c 100644 --- a/packages/nc-gui/components/smartsheet/Kanban.vue +++ b/packages/nc-gui/components/smartsheet/Kanban.vue @@ -22,6 +22,7 @@ import { provide, useAttachment, useKanbanViewStoreOrThrow, + useUndoRedo, } from '#imports' import type { Row as RowType } from '~/lib' @@ -84,6 +85,8 @@ const { isUIAllowed } = useUIPermission() const { appInfo } = $(useGlobal()) +const { addUndo } = useUndoRedo() + provide(IsFormInj, ref(false)) provide(IsGalleryInj, ref(false)) @@ -212,7 +215,7 @@ function onMoveCallback(event: { draggedContext: { futureIndex: number } }) { } } -async function onMoveStack(event: any) { +async function onMoveStack(event: any, undo = false) { if (event.moved) { const { oldIndex, newIndex } = event.moved const { fk_grp_col_id, meta: stack_meta } = kanbanMetaData.value @@ -223,6 +226,27 @@ async function onMoveStack(event: any) { await updateKanbanMeta({ meta: stackMetaObj, }) + if (!undo) { + addUndo({ + undo: { + fn: async (e: any) => { + const temp = groupingFieldColOptions.value.splice(e.moved.newIndex, 1) + groupingFieldColOptions.value.splice(e.moved.oldIndex, 0, temp[0]) + await onMoveStack(e, true) + }, + args: [{ moved: { oldIndex, newIndex } }], + }, + redo: { + fn: async (e: any) => { + const temp = groupingFieldColOptions.value.splice(e.moved.oldIndex, 1) + groupingFieldColOptions.value.splice(e.moved.newIndex, 0, temp[0]) + await onMoveStack(e, true) + }, + args: [{ moved: { oldIndex, newIndex } }, true], + }, + scope: view.value?.title, + }) + } } }