From 4786c550402d29ec3d724fcf7c3df5600ebc75c7 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Tue, 9 Aug 2022 16:12:43 +0200 Subject: [PATCH 01/31] fix(gui-v2): pass unique row+col key to attachment cell for dropzone refs --- .../components/cell/attachment/index.vue | 30 +++++++++---------- .../nc-gui-v2/components/smartsheet/Cell.vue | 10 +++---- .../nc-gui-v2/components/smartsheet/Grid.vue | 9 ++++-- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/packages/nc-gui-v2/components/cell/attachment/index.vue b/packages/nc-gui-v2/components/cell/attachment/index.vue index d1a385c2c9..6c6c8d36d9 100644 --- a/packages/nc-gui-v2/components/cell/attachment/index.vue +++ b/packages/nc-gui-v2/components/cell/attachment/index.vue @@ -6,21 +6,17 @@ import { useSortable } from './sort' import Carousel from './Carousel.vue' import { onMounted, ref, useDropZone, watch } from '#imports' import { isImage, openLink } from '~/utils' -import MaterialSymbolsAttachFile from '~icons/material-symbols/attach-file' -import MaterialArrowExpandIcon from '~icons/mdi/arrow-expand' -import MaterialSymbolsFileCopyOutline from '~icons/material-symbols/file-copy-outline' -import MdiReload from '~icons/mdi/reload' -import IcOutlineInsertDriveFile from '~icons/ic/outline-insert-drive-file' interface Props { modelValue: string | Record[] | null + rowIndex: number } interface Emits { (event: 'update:modelValue', value: string | Record): void } -const { modelValue } = defineProps() +const { modelValue, rowIndex } = defineProps() const emits = defineEmits() @@ -60,7 +56,7 @@ onKeyDown('Escape', () => { /** if possible, on mounted we try to fetch the relevant `td` cell to use as a dropzone */ onMounted(() => { if (typeof document !== 'undefined') { - dropZoneRef.value = document.querySelector(`td[data-col="${column.value.id}"]`) as HTMLTableDataCellElement + dropZoneRef.value = document.querySelector(`td[data-key="${rowIndex}${column.value.id}"]`) as HTMLTableDataCellElement } }) @@ -73,7 +69,7 @@ onMounted(() => { Drop here @@ -100,12 +96,15 @@ onMounted(() => { @@ -152,6 +148,10 @@ onMounted(() => { From cf42def81d664404d321a102af19ad1e82016920 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 9 Aug 2022 15:32:17 +0530 Subject: [PATCH 11/31] refactor(gui-v2): `add new row` size correction Signed-off-by: Pranav C --- .../nc-gui-v2/components/smartsheet/Grid.vue | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/packages/nc-gui-v2/components/smartsheet/Grid.vue b/packages/nc-gui-v2/components/smartsheet/Grid.vue index ab3f79a9dd..c8cf24defa 100644 --- a/packages/nc-gui-v2/components/smartsheet/Grid.vue +++ b/packages/nc-gui-v2/components/smartsheet/Grid.vue @@ -126,7 +126,7 @@ const makeEditable = (row: Row, col: ColumnType) => { return } if (!isPkAvail.value && !row.rowMeta.new) { - message.info("Update not allowed for table which doesn't have primary Key") + message.info('Update not allowed for table which doesn\'t have primary Key') return } if (col.ai) { @@ -190,35 +190,34 @@ const onKeyDown = async (e: KeyboardEvent) => { e.preventDefault() if (selected.row < data.value.length - 1) selected.row++ break - default: - { - const rowObj = data.value[selected.row] - const columnObj = fields.value[selected.col] - - if (e.metaKey || e.ctrlKey) { - switch (e.keyCode) { - // copy - ctrl/cmd +c - case 67: - await copy(rowObj.row[columnObj.title] || '') - break - } + default: { + const rowObj = data.value[selected.row] + const columnObj = fields.value[selected.col] + + if (e.metaKey || e.ctrlKey) { + switch (e.keyCode) { + // copy - ctrl/cmd +c + case 67: + await copy(rowObj.row[columnObj.title] || '') + break } + } - if (editEnabled || e.ctrlKey || e.altKey || e.metaKey) { - return - } + if (editEnabled || e.ctrlKey || e.altKey || e.metaKey) { + return + } - /** on letter key press make cell editable and empty */ - if (e?.key?.length === 1) { - if (!isPkAvail && !rowObj.rowMeta.new) { - return message.info("Update not allowed for table which doesn't have primary Key") - } - if (makeEditable(rowObj, columnObj)) { - rowObj.row[columnObj.title] = '' - } - // editEnabled = true + /** on letter key press make cell editable and empty */ + if (e?.key?.length === 1) { + if (!isPkAvail && !rowObj.rowMeta.new) { + return message.info('Update not allowed for table which doesn\'t have primary Key') } + if (makeEditable(rowObj, columnObj)) { + rowObj.row[columnObj.title] = '' + } + // editEnabled = true } + } break } } @@ -253,7 +252,8 @@ const onNavigate = (dir: NavigateDir) => {
- +
@@ -304,6 +304,7 @@ const onNavigate = (dir: NavigateDir) => { class="group-hover:flex w-full items-center justify-between p-1" > +
From b7c3f032d8839bea3b1242d1ee15ef6d27d3835d Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 9 Aug 2022 16:04:31 +0530 Subject: [PATCH 12/31] refactor(gui-v2): skip outside click handler if active cell is json or virtual Signed-off-by: Pranav C --- .../components/dashboard/TreeView.vue | 25 +++----- .../nc-gui-v2/components/smartsheet/Grid.vue | 61 +++++++++++-------- 2 files changed, 41 insertions(+), 45 deletions(-) diff --git a/packages/nc-gui-v2/components/dashboard/TreeView.vue b/packages/nc-gui-v2/components/dashboard/TreeView.vue index 565a314a00..60528bf2b7 100644 --- a/packages/nc-gui-v2/components/dashboard/TreeView.vue +++ b/packages/nc-gui-v2/components/dashboard/TreeView.vue @@ -1,38 +1,28 @@