From 8c0113989d0b240962c5722ed39607598c98e8c6 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 19 Aug 2022 15:22:38 +0800 Subject: [PATCH] fix(gui-v2): sorting / filtering in share base --- packages/nc-gui-v2/composables/useViewData.ts | 6 +++++- packages/nc-gui-v2/composables/useViewSorts.ts | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui-v2/composables/useViewData.ts b/packages/nc-gui-v2/composables/useViewData.ts index 70eac6ceda..85768d91eb 100644 --- a/packages/nc-gui-v2/composables/useViewData.ts +++ b/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[]) => 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() diff --git a/packages/nc-gui-v2/composables/useViewSorts.ts b/packages/nc-gui-v2/composables/useViewSorts.ts index e343fd14f2..82a918d222 100644 --- a/packages/nc-gui-v2/composables/useViewSorts.ts +++ b/packages/nc-gui-v2/composables/useViewSorts.ts @@ -17,9 +17,9 @@ export function useViewSorts( const { isSharedBase } = useProject() const sorts = computed({ - 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