From aa21eeba3455b7d18c6299bfc0efda39c6e7efd0 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 10 Sep 2022 16:19:16 +0800 Subject: [PATCH] feat(nc-gui): save the value after drag-n-drop --- .../nc-gui/components/smartsheet/Kanban.vue | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Kanban.vue b/packages/nc-gui/components/smartsheet/Kanban.vue index cd386a3aa8..88c2d3b07a 100644 --- a/packages/nc-gui/components/smartsheet/Kanban.vue +++ b/packages/nc-gui/components/smartsheet/Kanban.vue @@ -31,10 +31,8 @@ const expandedFormDlg = ref(false) const expandedFormRow = ref() const expandedFormRowState = ref>() -const { loadData, paginationData, formattedKanbanData, loadKanbanData, kanbanData, changePage, addEmptyRow } = useViewData( - meta, - view as any, -) +const { loadData, paginationData, formattedKanbanData, updateOrSaveRow, loadKanbanData, kanbanData, changePage, addEmptyRow } = + useViewData(meta, view as any) const { isUIAllowed } = useUIPermission() @@ -86,8 +84,6 @@ const attachments = (record: any): Array => { const reloadAttachments = ref(false) -const drag = ref(false) - reloadViewDataHook?.on(async () => { await loadData() await loadKanbanData() @@ -111,9 +107,18 @@ const expandFormClick = async (e: MouseEvent, row: RowType) => { } } -function onMove(event: any) { - const { newIndex, element, oldIndex } = event.added || event.moved || event.removed - // TODO: +async function onMove(event: any, stackKey: string) { + // const { newIndex, element, oldIndex } = event.added || event.moved || event.removed + if (event.added) { + // TODO: change current groupingField to stackKey + console.log(event.added.element) + console.log(stackKey) + // TODO: groupField + const groupingField = 'singleSelect2' + const ele = event.added.element + ele.row[groupingField] = stackKey + await updateOrSaveRow(ele, groupingField) + } } openNewRecordFormHook?.on(async () => { @@ -125,7 +130,7 @@ const stacks = ref([]) stacks.value = Object.keys(formattedKanbanData) watch(formattedKanbanData, (v) => { if (v) { - stacks.value = Object.keys(v).map((o, idx) => ({ key: o, idx })) + stacks.value = Object.keys(v).map((o, id) => ({ key: o, id })) } }) @@ -134,9 +139,9 @@ watch(formattedKanbanData, (v) => {
- +