From ec25499f7c14c5168de5eb5b29147a85aca0ed88 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 19 Aug 2022 12:11:31 +0800 Subject: [PATCH] fix(gui-v2): sort for share base --- packages/nc-gui-v2/composables/useViewSorts.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/nc-gui-v2/composables/useViewSorts.ts b/packages/nc-gui-v2/composables/useViewSorts.ts index b6a3fa6bc0..e343fd14f2 100644 --- a/packages/nc-gui-v2/composables/useViewSorts.ts +++ b/packages/nc-gui-v2/composables/useViewSorts.ts @@ -7,11 +7,15 @@ export function useViewSorts( reloadData?: () => void, ) { const _sorts = ref([]) + const { sorts: sharedViewSorts, sharedView } = useSharedView() const reloadHook = inject(ReloadViewDataHookInj) + const isPublic = inject(IsPublicInj, ref(false)) + const { isSharedBase } = useProject() + const sorts = computed({ get: () => (isPublic.value ? sharedViewSorts.value : _sorts.value), set: (value) => { @@ -39,9 +43,8 @@ export function useViewSorts( } const saveOrUpdate = async (sort: SortType, i: number) => { - // TODO: - // if (!this.shared && this._isUIAllowed('sortSync')) { - if (isPublic.value) { + if (isPublic.value || isSharedBase) { + // FIXME: not working for isSharedBase case sorts.value[i] = sort sorts.value = [...sorts.value] return @@ -66,10 +69,7 @@ export function useViewSorts( } const deleteSort = async (sort: SortType, i: number) => { - // TOOD: - // if (!this.shared && sort.id && this._isUIAllowed('sortSync')) { - - if (isUIAllowed('sortSync') && sort.id && !isPublic.value) { + if (isUIAllowed('sortSync') && sort.id && !isPublic.value && !isSharedBase) { await $api.dbTableSort.delete(sort.id) } sorts.value.splice(i, 1)