|
|
@ -1,6 +1,6 @@ |
|
|
|
import type {FilterType, GalleryType, GridType, KanbanType} from 'nocodb-sdk' |
|
|
|
import type { FilterType, GalleryType, GridType, KanbanType } from 'nocodb-sdk' |
|
|
|
import type {ComputedRef, Ref} from 'vue' |
|
|
|
import type { ComputedRef, Ref } from 'vue' |
|
|
|
import {useNuxtApp} from '#imports' |
|
|
|
import { useNuxtApp } from '#imports' |
|
|
|
import useUIPermission from '~/composables/useUIPermission' |
|
|
|
import useUIPermission from '~/composables/useUIPermission' |
|
|
|
|
|
|
|
|
|
|
|
export function useViewFilters( |
|
|
|
export function useViewFilters( |
|
|
@ -8,14 +8,13 @@ export function useViewFilters( |
|
|
|
parentId?: string, |
|
|
|
parentId?: string, |
|
|
|
autoApply?: ComputedRef<boolean>, |
|
|
|
autoApply?: ComputedRef<boolean>, |
|
|
|
reloadData?: () => void, |
|
|
|
reloadData?: () => void, |
|
|
|
shared = false |
|
|
|
shared = false, |
|
|
|
) { |
|
|
|
) { |
|
|
|
|
|
|
|
|
|
|
|
// todo: update swagger
|
|
|
|
// todo: update swagger
|
|
|
|
const filters = ref<(FilterType & { status?: 'update' | 'delete' | 'create'; parentId?: string })[]>([]) |
|
|
|
const filters = ref<(FilterType & { status?: 'update' | 'delete' | 'create'; parentId?: string })[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
const {$api} = useNuxtApp() |
|
|
|
const { $api } = useNuxtApp() |
|
|
|
const {isUIAllowed} = useUIPermission() |
|
|
|
const { isUIAllowed } = useUIPermission() |
|
|
|
|
|
|
|
|
|
|
|
const loadFilters = async () => { |
|
|
|
const loadFilters = async () => { |
|
|
|
if (parentId) { |
|
|
|
if (parentId) { |
|
|
@ -45,7 +44,6 @@ export function useViewFilters( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const deleteFilter = async (filter: FilterType & { status: string }, i: number) => { |
|
|
|
const deleteFilter = async (filter: FilterType & { status: string }, i: number) => { |
|
|
|
|
|
|
|
|
|
|
|
if (shared || !isUIAllowed('filterSync')) { |
|
|
|
if (shared || !isUIAllowed('filterSync')) { |
|
|
|
const _filters = unref(filters.value) |
|
|
|
const _filters = unref(filters.value) |
|
|
|
_filters.splice(i, 1) |
|
|
|
_filters.splice(i, 1) |
|
|
@ -104,5 +102,5 @@ export function useViewFilters( |
|
|
|
await saveOrUpdate(filters.value[index], index, true) |
|
|
|
await saveOrUpdate(filters.value[index], index, true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return {filters, loadFilters, sync, deleteFilter, saveOrUpdate, addFilter, addFilterGroup} |
|
|
|
return { filters, loadFilters, sync, deleteFilter, saveOrUpdate, addFilter, addFilterGroup } |
|
|
|
} |
|
|
|
} |
|
|
|