Browse Source

fix(nc-gui): use default limit from app info if specified

pull/3622/head
Wing-Kam Wong 2 years ago
parent
commit
0d34aa76d0
  1. 7
      packages/nc-gui/composables/useSharedView.ts
  2. 13
      packages/nc-gui/composables/useViewData.ts

7
packages/nc-gui/composables/useSharedView.ts

@ -1,13 +1,16 @@
import type { ExportTypes, FilterType, PaginatedType, SortType, TableType, ViewType } from 'nocodb-sdk' import type { ExportTypes, FilterType, PaginatedType, SortType, TableType, ViewType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
import { useGlobal } from '#imports'
export function useSharedView() { export function useSharedView() {
const nestedFilters = useState<(FilterType & { status?: 'update' | 'delete' | 'create'; parentId?: string })[]>( const nestedFilters = useState<(FilterType & { status?: 'update' | 'delete' | 'create'; parentId?: string })[]>(
'nestedFilters', 'nestedFilters',
() => [], () => [],
) )
const paginationData = useState<PaginatedType>('paginationData', () => ({ page: 1, pageSize: 25 })) const { appInfo } = $(useGlobal())
const appInfoDefaultLimit = appInfo?.defaultLimit || 25
const paginationData = useState<PaginatedType>('paginationData', () => ({ page: 1, pageSize: appInfoDefaultLimit }))
const sharedView = useState<ViewType>('sharedView') const sharedView = useState<ViewType>('sharedView')
const sorts = useState<SortType[]>('sorts', () => []) const sorts = useState<SortType[]>('sorts', () => [])
const password = useState<string | undefined>('password') const password = useState<string | undefined>('password')
@ -55,7 +58,7 @@ export function useSharedView() {
const fetchSharedViewData = async () => { const fetchSharedViewData = async () => {
const page = paginationData.value.page || 1 const page = paginationData.value.page || 1
const pageSize = paginationData.value.pageSize || 25 const pageSize = paginationData.value.pageSize || appInfoDefaultLimit
const { data } = await $api.public.dataList( const { data } = await $api.public.dataList(
sharedView?.value?.uuid, sharedView?.value?.uuid,

13
packages/nc-gui/composables/useViewData.ts

@ -10,6 +10,7 @@ import {
extractSdkResponseErrorMsg, extractSdkResponseErrorMsg,
getHTMLEncodedText, getHTMLEncodedText,
useApi, useApi,
useGlobal,
useProject, useProject,
useUIPermission, useUIPermission,
} from '#imports' } from '#imports'
@ -43,7 +44,9 @@ export function useViewData(
const { t } = useI18n() const { t } = useI18n()
const { api, isLoading, error } = useApi() const { api, isLoading, error } = useApi()
const _paginationData = ref<PaginatedType>({ page: 1, pageSize: 25 }) const { appInfo } = $(useGlobal())
const appInfoDefaultLimit = appInfo?.defaultLimit || 25
const _paginationData = ref<PaginatedType>({ page: 1, pageSize: appInfoDefaultLimit })
const aggCommentCount = ref<{ row_id: string; count: number }[]>([]) const aggCommentCount = ref<{ row_id: string; count: number }[]>([])
const galleryData = ref<GalleryType>() const galleryData = ref<GalleryType>()
const formColumnData = ref<FormType>() const formColumnData = ref<FormType>()
@ -79,8 +82,8 @@ export function useViewData(
}) })
const queryParams = computed(() => ({ const queryParams = computed(() => ({
offset: ((paginationData.value?.page ?? 0) - 1) * (paginationData.value?.pageSize ?? 25), offset: ((paginationData.value?.page ?? 0) - 1) * (paginationData.value?.pageSize ?? appInfoDefaultLimit),
limit: paginationData.value?.pageSize ?? 25, limit: paginationData.value?.pageSize ?? appInfoDefaultLimit,
where: where?.value ?? '', where: where?.value ?? '',
})) }))
@ -116,7 +119,7 @@ export function useViewData(
// total records in the current table // total records in the current table
const count = paginationData.value?.totalRows ?? Infinity const count = paginationData.value?.totalRows ?? Infinity
// the number of rows in a page // the number of rows in a page
const size = paginationData.value?.pageSize ?? 25 const size = paginationData.value?.pageSize ?? appInfoDefaultLimit
// the current page number // 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 // the maximum possible page given the current count and the size
@ -261,7 +264,7 @@ export function useViewData(
async function changePage(page: number) { async function changePage(page: number) {
paginationData.value.page = page 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') $e('a:grid:pagination')
} }

Loading…
Cancel
Save