diff --git a/packages/nc-gui/composables/useSharedView.ts b/packages/nc-gui/composables/useSharedView.ts index 336aa3ea65..0d1163fdae 100644 --- a/packages/nc-gui/composables/useSharedView.ts +++ b/packages/nc-gui/composables/useSharedView.ts @@ -1,13 +1,15 @@ import type { ExportTypes, FilterType, PaginatedType, RequestParams, SortType, TableType, ViewType } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk' -import { useNuxtApp } from '#app' +import { useGlobal, useNuxtApp } from '#imports' export function useSharedView() { const nestedFilters = useState<(FilterType & { status?: 'update' | 'delete' | 'create'; parentId?: string })[]>( 'nestedFilters', () => [], ) - const paginationData = useState('paginationData', () => ({ page: 1, pageSize: 25 })) + const { appInfo } = $(useGlobal()) + const appInfoDefaultLimit = appInfo.defaultLimit || 25 + const paginationData = useState('paginationData', () => ({ page: 1, pageSize: appInfoDefaultLimit })) const sharedView = useState('sharedView', () => undefined) const sorts = useState('sorts', () => []) const password = useState('password', () => undefined) @@ -57,7 +59,7 @@ export function useSharedView() { if (!sharedView.value) return const page = paginationData.value.page || 1 - const pageSize = paginationData.value.pageSize || 25 + const pageSize = paginationData.value.pageSize || appInfoDefaultLimit const { data } = await $api.public.dataList( sharedView.value.uuid!, diff --git a/packages/nc-gui/composables/useViewData.ts b/packages/nc-gui/composables/useViewData.ts index 7db6a95e2a..0a67928c87 100644 --- a/packages/nc-gui/composables/useViewData.ts +++ b/packages/nc-gui/composables/useViewData.ts @@ -9,6 +9,7 @@ import { extractSdkResponseErrorMsg, getHTMLEncodedText, useApi, + useGlobal, useI18n, useNuxtApp, useProject, @@ -44,7 +45,9 @@ export function useViewData( const { t } = useI18n() const { api, isLoading, error } = useApi() - const _paginationData = ref({ page: 1, pageSize: 25 }) + const { appInfo } = $(useGlobal()) + const appInfoDefaultLimit = appInfo.defaultLimit || 25 + const _paginationData = ref({ page: 1, pageSize: appInfoDefaultLimit }) const aggCommentCount = ref<{ row_id: string; count: number }[]>([]) const galleryData = ref() const formColumnData = ref() @@ -79,8 +82,8 @@ export function useViewData( }) const queryParams = computed(() => ({ - offset: ((paginationData.value?.page ?? 0) - 1) * (paginationData.value?.pageSize ?? 25), - limit: paginationData.value?.pageSize ?? 25, + offset: ((paginationData.value.page ?? 0) - 1) * (paginationData.value.pageSize ?? appInfoDefaultLimit), + limit: paginationData.value.pageSize ?? appInfoDefaultLimit, where: where?.value ?? '', })) @@ -116,9 +119,9 @@ export function useViewData( // total records in the current table const count = paginationData.value?.totalRows ?? Infinity // the number of rows in a page - const size = paginationData.value?.pageSize ?? 25 + const size = paginationData.value.pageSize ?? appInfoDefaultLimit // the current page number - const currentPage = paginationData.value?.page ?? 1 + const currentPage = paginationData.value.page ?? 1 // the maximum possible page given the current count and the size const mxPage = Math.ceil(count / size) // calculate targetPage where 1 <= targetPage <= mxPage @@ -263,7 +266,7 @@ export function useViewData( async function changePage(page: number) { paginationData.value.page = page - await loadData({ offset: (page - 1) * (paginationData.value.pageSize || 25), where: where?.value } as any) + await loadData({ offset: (page - 1) * (paginationData.value.pageSize || appInfoDefaultLimit), where: where?.value } as any) $e('a:grid:pagination') }