From ccc8a04e43d0de0c90b9b79ed8bfca2dc22ff780 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 30 Sep 2022 12:04:46 +0800 Subject: [PATCH] feat(nc-gui): introduce delete row in kanban view --- .../nc-gui/components/smartsheet/Kanban.vue | 427 ++++++++++-------- .../nc-gui/composables/useKanbanViewStore.ts | 59 +++ 2 files changed, 294 insertions(+), 192 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Kanban.vue b/packages/nc-gui/components/smartsheet/Kanban.vue index 9785bc69cd..639daa980c 100644 --- a/packages/nc-gui/components/smartsheet/Kanban.vue +++ b/packages/nc-gui/components/smartsheet/Kanban.vue @@ -66,6 +66,7 @@ const { deleteStack, removeRowFromUncategorizedStack, shouldScrollToRight, + deleteRow, } = useKanbanViewStoreOrThrow() const { isUIAllowed } = useUIPermission() @@ -82,6 +83,8 @@ provide(IsKanbanInj, ref(true)) provide(ReadonlyInj, !isUIAllowed('xcDatatableEditable')) +const hasEditPermission = $computed(() => isUIAllowed('xcDatatableEditable')) + const fields = inject(FieldsInj, ref([])) const kanbanContainerRef = ref() @@ -105,7 +108,7 @@ reloadViewMetaHook?.on(async () => { }) const expandForm = (row: RowType, state?: Record) => { - if (!isUIAllowed('xcDatatableEditable')) return + if (!hasEditPermission) return const rowId = extractPkFromRow(row.row, meta.value!.columns!) @@ -123,6 +126,25 @@ const expandForm = (row: RowType, state?: Record) => { } } +const _contextMenu = ref(false) +const contextMenu = computed({ + get: () => _contextMenu.value, + set: (val) => { + if (hasEditPermission) { + _contextMenu.value = val + } + }, +}) + +const contextMenuTarget = ref(null) + +const showContextMenu = (e: MouseEvent, target?: RowType) => { + e.preventDefault() + if (target) { + contextMenuTarget.value = target + } +} + const expandedFormOnRowIdDlg = computed({ get() { return !!route.query.rowId @@ -250,212 +272,233 @@ watch( } }, ) + +// reset context menu target on hide +watch(contextMenu, () => { + if (!contextMenu.value) { + contextMenuTarget.value = null + } +})