Browse Source

Merge pull request #3881 from nocodb/fix/3859-shared-view-sort

Fix: Shared grid view sort
pull/3888/head
Raju Udava 2 years ago committed by GitHub
parent
commit
c72e9ae4ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      packages/nc-gui/composables/useSharedView.ts
  2. 7
      packages/nc-gui/composables/useViewData.ts

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

@ -3,10 +3,7 @@ import { UITypes } from 'nocodb-sdk'
import { computed, useGlobal, useMetas, useNuxtApp, useState } from '#imports'
export function useSharedView() {
const nestedFilters = useState<(FilterType & { status?: 'update' | 'delete' | 'create'; parentId?: string })[]>(
'nestedFilters',
() => [],
)
const nestedFilters = ref<(FilterType & { status?: 'update' | 'delete' | 'create'; parentId?: string })[]>([])
const { appInfo } = $(useGlobal())
@ -16,7 +13,7 @@ export function useSharedView() {
const sharedView = useState<ViewType | undefined>('sharedView', () => undefined)
const sorts = useState<SortType[]>('sorts', () => [])
const sorts = ref<SortType[]>([])
const password = useState<string | undefined>('password', () => undefined)
@ -64,7 +61,7 @@ export function useSharedView() {
Object.keys(relatedMetas).forEach((key) => setMeta(relatedMetas[key]))
}
const fetchSharedViewData = async () => {
const fetchSharedViewData = async ({ sortsArr, filtersArr }: { sortsArr: SortType[]; filtersArr: FilterType[] }) => {
if (!sharedView.value) return
const page = paginationData.value.page || 1
@ -74,8 +71,8 @@ export function useSharedView() {
sharedView.value.uuid!,
{
offset: (page - 1) * pageSize,
filterArrJson: JSON.stringify(nestedFilters.value),
sortArrJson: JSON.stringify(sorts.value),
filterArrJson: JSON.stringify(filtersArr ?? nestedFilters.value),
sortArrJson: JSON.stringify(sortsArr ?? sorts.value),
} as any,
{
headers: {

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

@ -180,7 +180,7 @@ export function useViewData(
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }),
where: where?.value,
})
: await fetchSharedViewData()
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value })
formattedData.value = formatData(response.list)
paginationData.value = response.pageInfo
if (viewMeta.value?.type === ViewTypes.GRID) {
@ -271,7 +271,10 @@ export function useViewData(
async function changePage(page: number) {
paginationData.value.page = page
await loadData({ offset: (page - 1) * (paginationData.value.pageSize || appInfoDefaultLimit), where: where?.value } as any)
await loadData({
offset: (page - 1) * (paginationData.value.pageSize || appInfoDefaultLimit),
where: where?.value,
} as any)
$e('a:grid:pagination')
}

Loading…
Cancel
Save