From fed1c7ba5c0b47a5f21c0962f6ef2b0de907d7a3 Mon Sep 17 00:00:00 2001 From: Mert E Date: Mon, 29 Apr 2024 11:52:21 +0300 Subject: [PATCH] feat: virtual scroll for grid (#8356) * feat: virtual scroll for grid * feat: improve virtual scroll * fix: remove unused expose & ref * feat: move row ltar helpers to parent level * fix: use shared composable for useMetas * fix: column add issue * fix: reload issue * feat: move cell state to computed * chore: lint * fix: null check for sticky field * fix: PR requested changes * fix: shared views * fix: provide row store calls * test: avoid all rows selector * fix: group by * fix: include isVirtualCol in cellMeta * fix: split colMeta and cellMeta * chore: lint * test: edit column flakiness * test: renderColumn for dashboard grid * test: user column test flakiness --- .../components/shared-view/Calendar.vue | 2 + .../nc-gui/components/shared-view/Gallery.vue | 2 + .../nc-gui/components/shared-view/Grid.vue | 2 + .../nc-gui/components/shared-view/Kanban.vue | 2 + .../nc-gui/components/shared-view/Map.vue | 2 + .../nc-gui/components/smartsheet/Cell.vue | 121 +-- .../nc-gui/components/smartsheet/Form.vue | 1 - packages/nc-gui/components/smartsheet/Row.vue | 17 +- .../smartsheet/SharedMapMarkerPopup.vue | 5 +- .../components/smartsheet/TableDataCell.vue | 4 +- .../components/smartsheet/VirtualCell.vue | 61 +- .../smartsheet/column/DefaultValue.vue | 4 +- .../smartsheet/expanded-form/index.vue | 2 + .../smartsheet/grid/GroupByTable.vue | 1 + .../components/smartsheet/grid/Table.vue | 909 ++++++++++++------ .../nc-gui/components/tabs/Smartsheet.vue | 5 +- .../composables/useExpandedFormStore.ts | 2 +- packages/nc-gui/composables/useMetas.ts | 4 +- .../composables/useMultiSelect/index.ts | 50 +- .../composables/useSharedFormViewStore.ts | 4 +- .../composables/useSmartsheetLtarHelpers.ts | 249 +++++ .../composables/useSmartsheetRowStore.ts | 266 +---- packages/nc-gui/lib/types.ts | 1 + .../pages/Dashboard/Grid/Column/index.ts | 3 +- .../playwright/pages/Dashboard/Grid/index.ts | 44 +- .../Dashboard/common/Cell/UserOptionCell.ts | 2 +- .../pages/Dashboard/common/Cell/index.ts | 1 + .../pages/Dashboard/common/Topbar/index.ts | 1 + .../tests/db/columns/columnUserSelect.spec.ts | 6 +- .../db/features/keyboardShortcuts.spec.ts | 3 + 30 files changed, 1071 insertions(+), 705 deletions(-) create mode 100644 packages/nc-gui/composables/useSmartsheetLtarHelpers.ts diff --git a/packages/nc-gui/components/shared-view/Calendar.vue b/packages/nc-gui/components/shared-view/Calendar.vue index 83e91cd2a7..1e22a4160a 100644 --- a/packages/nc-gui/components/shared-view/Calendar.vue +++ b/packages/nc-gui/components/shared-view/Calendar.vue @@ -28,6 +28,8 @@ provide(IsPublicInj, ref(true)) useProvideViewColumns(sharedView, meta, () => reloadEventHook?.trigger(), true) +useProvideSmartsheetLtarHelpers(meta) + useProvideSmartsheetStore(sharedView, meta, true, ref([]), nestedFilters) useProvideKanbanViewStore(meta, sharedView) diff --git a/packages/nc-gui/components/shared-view/Gallery.vue b/packages/nc-gui/components/shared-view/Gallery.vue index 890c52f229..7de66fdc71 100644 --- a/packages/nc-gui/components/shared-view/Gallery.vue +++ b/packages/nc-gui/components/shared-view/Gallery.vue @@ -32,6 +32,8 @@ provide(IsPublicInj, ref(true)) useProvideViewColumns(sharedView, meta, () => reloadEventHook?.trigger(), true) +useProvideSmartsheetLtarHelpers(meta) + useProvideSmartsheetStore(sharedView, meta, true, ref([]), nestedFilters) useProvideKanbanViewStore(meta, sharedView) diff --git a/packages/nc-gui/components/shared-view/Grid.vue b/packages/nc-gui/components/shared-view/Grid.vue index 7e14057284..85fd1ff4c4 100644 --- a/packages/nc-gui/components/shared-view/Grid.vue +++ b/packages/nc-gui/components/shared-view/Grid.vue @@ -43,6 +43,8 @@ provide(IsLockedInj, isLocked) useProvideViewColumns(sharedView, meta, () => reloadEventHook?.trigger(), true) useProvideViewGroupBy(sharedView, meta, xWhere, true) +useProvideSmartsheetLtarHelpers(meta) + if (signedIn.value) { try { await loadProject() diff --git a/packages/nc-gui/components/shared-view/Kanban.vue b/packages/nc-gui/components/shared-view/Kanban.vue index ab88c584bf..c92d9bc9f2 100644 --- a/packages/nc-gui/components/shared-view/Kanban.vue +++ b/packages/nc-gui/components/shared-view/Kanban.vue @@ -27,6 +27,8 @@ provide(IsPublicInj, ref(true)) useProvideViewColumns(sharedView, meta, () => reloadEventHook?.trigger(), true) +useProvideSmartsheetLtarHelpers(meta) + useProvideSmartsheetStore(sharedView, meta, true, ref([]), nestedFilters) useProvideKanbanViewStore(meta, sharedView, true) diff --git a/packages/nc-gui/components/shared-view/Map.vue b/packages/nc-gui/components/shared-view/Map.vue index ccadbc2452..2e64490fce 100644 --- a/packages/nc-gui/components/shared-view/Map.vue +++ b/packages/nc-gui/components/shared-view/Map.vue @@ -27,6 +27,8 @@ provide(IsPublicInj, ref(true)) useProvideViewColumns(sharedView, meta, () => reloadEventHook?.trigger(), true) +useProvideSmartsheetLtarHelpers(meta) + useProvideSmartsheetStore(sharedView, meta, true, ref([]), nestedFilters) useProvideMapViewStore(meta, sharedView, true) diff --git a/packages/nc-gui/components/smartsheet/Cell.vue b/packages/nc-gui/components/smartsheet/Cell.vue index 23e6de92db..fb8fb8d7c4 100644 --- a/packages/nc-gui/components/smartsheet/Cell.vue +++ b/packages/nc-gui/components/smartsheet/Cell.vue @@ -154,43 +154,10 @@ const onContextmenu = (e: MouseEvent) => { e.stopPropagation() } } - -// Todo: move intersection logic to a separate component or a vue directive -const intersected = ref(false) - -const intersectionObserver = ref() - -const elementToObserve = ref() - -// load the cell only when it is in the viewport -function initIntersectionObserver() { - intersectionObserver.value = new IntersectionObserver((entries) => { - entries.forEach((entry) => { - // if the cell is in the viewport, load the cell and disconnect the observer - if (entry.isIntersecting) { - intersected.value = true - intersectionObserver.value?.disconnect() - intersectionObserver.value = undefined - } - }) - }) -} - -// observe the cell when it is mounted -onMounted(() => { - initIntersectionObserver() - intersectionObserver.value?.observe(elementToObserve.value!) -}) - -// disconnect the observer when the cell is unmounted -onUnmounted(() => { - intersectionObserver.value?.disconnect() -}) diff --git a/packages/nc-gui/components/smartsheet/Form.vue b/packages/nc-gui/components/smartsheet/Form.vue index f5d7b07245..d02c189500 100644 --- a/packages/nc-gui/components/smartsheet/Form.vue +++ b/packages/nc-gui/components/smartsheet/Form.vue @@ -120,7 +120,6 @@ reloadEventHook.on(async () => { const { fields, showAll, hideAll } = useViewColumnsOrThrow() const { state, row } = useProvideSmartsheetRowStore( - meta, ref({ row: formState.value, oldRow: {}, diff --git a/packages/nc-gui/components/smartsheet/Row.vue b/packages/nc-gui/components/smartsheet/Row.vue index 4b5567e90e..502c14e5fc 100644 --- a/packages/nc-gui/components/smartsheet/Row.vue +++ b/packages/nc-gui/components/smartsheet/Row.vue @@ -1,6 +1,4 @@