Browse Source

feat: undo/redo for kanban view stacked by

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5332/head
mertmit 2 years ago
parent
commit
7d0f1f0504
  1. 28
      packages/nc-gui/components/smartsheet/toolbar/StackedBy.vue

28
packages/nc-gui/components/smartsheet/toolbar/StackedBy.vue

@ -14,6 +14,7 @@ import {
ref, ref,
useKanbanViewStoreOrThrow, useKanbanViewStoreOrThrow,
useMenuCloseOnEsc, useMenuCloseOnEsc,
useUndoRedo,
useViewColumns, useViewColumns,
watch, watch,
} from '#imports' } from '#imports'
@ -32,6 +33,8 @@ const { fields, loadViewColumns, metaColumnById } = useViewColumns(activeView, m
const { kanbanMetaData, loadKanbanMeta, loadKanbanData, updateKanbanMeta, groupingField } = useKanbanViewStoreOrThrow() const { kanbanMetaData, loadKanbanMeta, loadKanbanData, updateKanbanMeta, groupingField } = useKanbanViewStoreOrThrow()
const { addUndo } = useUndoRedo()
const open = ref(false) const open = ref(false)
useMenuCloseOnEsc(open) useMenuCloseOnEsc(open)
@ -46,16 +49,31 @@ watch(
{ immediate: true }, { immediate: true },
) )
const updateGroupingField = async (v: string) => {
await updateKanbanMeta({
fk_grp_col_id: v,
})
await loadKanbanMeta()
await loadKanbanData()
;(activeView.value?.view as KanbanType).fk_grp_col_id = v
}
const groupingFieldColumnId = computed({ const groupingFieldColumnId = computed({
get: () => kanbanMetaData.value.fk_grp_col_id, get: () => kanbanMetaData.value.fk_grp_col_id,
set: async (val) => { set: async (val) => {
if (val) { if (val) {
await updateKanbanMeta({ addUndo({
fk_grp_col_id: val, undo: {
fn: await updateGroupingField,
args: [kanbanMetaData.value.fk_grp_col_id],
},
redo: {
fn: await updateGroupingField,
args: [val],
},
}) })
await loadKanbanMeta()
await loadKanbanData() await updateGroupingField(val)
;(activeView.value?.view as KanbanType).fk_grp_col_id = val
} }
}, },
}) })

Loading…
Cancel
Save