Browse Source

fix(gui-v2): sorting / filtering in share base

pull/3234/head
Wing-Kam Wong 2 years ago
parent
commit
8c0113989d
  1. 6
      packages/nc-gui-v2/composables/useViewData.ts
  2. 4
      packages/nc-gui-v2/composables/useViewSorts.ts

6
packages/nc-gui-v2/composables/useViewData.ts

@ -2,7 +2,7 @@ import type { Api, ColumnType, FormType, GalleryType, PaginatedType, TableType,
import type { ComputedRef, Ref } from 'vue'
import { message } from 'ant-design-vue'
import { useNuxtApp } from '#app'
import { IsPublicInj, NOCO, extractPkFromRow, extractSdkResponseErrorMsg, useProject } from '#imports'
import { IsPublicInj, NOCO, extractPkFromRow, extractSdkResponseErrorMsg, useProject, useUIPermission } from '#imports'
const formatData = (list: Record<string, any>[]) =>
list.map((row) => ({
@ -42,6 +42,8 @@ export function useViewData(
const { project } = useProject()
const { fetchSharedViewData, paginationData: sharedPaginationData } = useSharedView()
const { $api } = useNuxtApp()
const { sorts, nestedFilters: filters } = useSharedView()
const { isUIAllowed } = useUIPermission()
const paginationData = computed({
get: () => (isPublic.value ? sharedPaginationData.value : _paginationData.value),
@ -109,6 +111,8 @@ export function useViewData(
const response = !isPublic.value
? await $api.dbViewRow.list('noco', project.value.id!, meta.value.id!, viewMeta!.value.id, {
...params,
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }),
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(filters.value) }),
where: where?.value,
})
: await fetchSharedViewData()

4
packages/nc-gui-v2/composables/useViewSorts.ts

@ -17,9 +17,9 @@ export function useViewSorts(
const { isSharedBase } = useProject()
const sorts = computed<SortType[]>({
get: () => (isPublic.value ? sharedViewSorts.value : _sorts.value),
get: () => (isPublic.value || isSharedBase ? sharedViewSorts.value : _sorts.value),
set: (value) => {
if (isPublic.value) {
if (isPublic.value || isSharedBase) {
sharedViewSorts.value = value
} else {
_sorts.value = value

Loading…
Cancel
Save