From 4f3d3b370287b2b6103af72772830989895b1179 Mon Sep 17 00:00:00 2001 From: flisowna Date: Thu, 22 Dec 2022 11:04:43 +0100 Subject: [PATCH] WIP changing page size limits for map view --- .../nc-gui/composables/useMapViewDataStore.ts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/composables/useMapViewDataStore.ts b/packages/nc-gui/composables/useMapViewDataStore.ts index 167f859b1e..c58f547a7b 100644 --- a/packages/nc-gui/composables/useMapViewDataStore.ts +++ b/packages/nc-gui/composables/useMapViewDataStore.ts @@ -1,6 +1,6 @@ import { reactive } from 'vue'; import type { ComputedRef, Ref } from 'vue' -import type { ColumnType, MapType, TableType, ViewType } from 'nocodb-sdk' +import type { ColumnType, MapType, PaginatedType, TableType, ViewType } from 'nocodb-sdk' import { ref, useInjectionState, useMetas } from '#imports' import type { Row } from '~/lib' @@ -13,10 +13,16 @@ const formatData = (list: Row[]) => rowMeta: {}, })) +const { appInfo } = $(useGlobal()) + +const appInfoDefaultLimit = 100 +const paginationData = ref({ page: 1, pageSize: appInfoDefaultLimit }) + const [useProvideMapViewStore, useMapViewStore] = useInjectionState( ( meta: Ref, viewMeta: Ref | ComputedRef<(ViewType & { id: string }) | undefined>, + where?: ComputedRef, ) => { const formattedData = ref([]) @@ -30,6 +36,12 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState( const geoDataFieldColumn = ref() + const queryParams = computed(() => ({ + // offset: ((paginationData.value.page ?? 0) - 1) * (paginationData.value.pageSize ?? appInfoDefaultLimit), + limit: paginationData.value.pageSize ?? appInfoDefaultLimit, + where: where?.value ?? '', + })) + async function loadMapMeta() { if (!viewMeta?.value?.id || !meta?.value?.columns) return mapMetaData.value = await $api.dbView.mapRead(viewMeta.value.id) @@ -40,7 +52,13 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState( async function loadMapData() { if (!viewMeta?.value?.id || !meta?.value?.columns) return - const res = await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!) + const res = await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!, { + ...queryParams.value, + // ...params, + // ...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }), + // ...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), + where: where?.value, + }) formattedData.value = formatData(res.list) }