|
|
|
@ -12,7 +12,7 @@ import { UITypes, isSystemColumn } from 'nocodb-sdk'
|
|
|
|
|
|
|
|
|
|
export function useViewFilters( |
|
|
|
|
view: Ref<ViewType | undefined>, |
|
|
|
|
parentId?: string, |
|
|
|
|
parentId: Ref<string | null>, |
|
|
|
|
autoApply?: ComputedRef<boolean>, |
|
|
|
|
reloadData?: () => void, |
|
|
|
|
_currentFilters?: Filter[], |
|
|
|
@ -240,14 +240,14 @@ export function useViewFilters(
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if (isWebhook || hookId) { |
|
|
|
|
if (parentId) { |
|
|
|
|
filters.value = (await $api.dbTableFilter.childrenRead(parentId)).list as Filter[] |
|
|
|
|
if (parentId.value) { |
|
|
|
|
filters.value = (await $api.dbTableFilter.childrenRead(parentId.value)).list as Filter[] |
|
|
|
|
} else if (hookId) { |
|
|
|
|
filters.value = (await $api.dbTableWebhookFilter.read(hookId)).list as Filter[] |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (parentId) { |
|
|
|
|
filters.value = (await $api.dbTableFilter.childrenRead(parentId)).list as Filter[] |
|
|
|
|
if (parentId.value) { |
|
|
|
|
filters.value = (await $api.dbTableFilter.childrenRead(parentId.value)).list as Filter[] |
|
|
|
|
} else { |
|
|
|
|
filters.value = (await $api.dbTableFilter.read(view.value!.id!)).list as Filter[] |
|
|
|
|
if (loadAllFilters) { |
|
|
|
@ -275,21 +275,25 @@ export function useViewFilters(
|
|
|
|
|
} else if (filter.status === 'update') { |
|
|
|
|
await $api.dbTableFilter.update(filter.id as string, { |
|
|
|
|
...filter, |
|
|
|
|
fk_parent_id: parentId, |
|
|
|
|
fk_parent_id: parentId.value, |
|
|
|
|
}) |
|
|
|
|
} else if (filter.status === 'create') { |
|
|
|
|
// extract children value if found to restore
|
|
|
|
|
const children = filters.value[+i]?.children |
|
|
|
|
if (hookId) { |
|
|
|
|
filters.value[+i] = (await $api.dbTableWebhookFilter.create(hookId, { |
|
|
|
|
...filter, |
|
|
|
|
fk_parent_id: parentId, |
|
|
|
|
fk_parent_id: parentId.value, |
|
|
|
|
})) as unknown as FilterType |
|
|
|
|
} else { |
|
|
|
|
filters.value[+i] = await $api.dbTableFilter.create(view?.value?.id as string, { |
|
|
|
|
...filter, |
|
|
|
|
fk_parent_id: parentId, |
|
|
|
|
fk_parent_id: parentId.value, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (children) filters.value[+i].children = children |
|
|
|
|
|
|
|
|
|
allFilters.value.push(filters.value[+i]) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -345,7 +349,7 @@ export function useViewFilters(
|
|
|
|
|
} else if (filter.id && filter.status !== 'create') { |
|
|
|
|
await $api.dbTableFilter.update(filter.id, { |
|
|
|
|
...filter, |
|
|
|
|
fk_parent_id: parentId, |
|
|
|
|
fk_parent_id: parentId.value, |
|
|
|
|
}) |
|
|
|
|
$e('a:filter:update', { |
|
|
|
|
logical: filter.logical_op, |
|
|
|
@ -354,7 +358,7 @@ export function useViewFilters(
|
|
|
|
|
} else { |
|
|
|
|
filters.value[i] = await $api.dbTableFilter.create(view.value.id!, { |
|
|
|
|
...filter, |
|
|
|
|
fk_parent_id: parentId, |
|
|
|
|
fk_parent_id: parentId.value, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
allFilters.value.push(filters.value[+i]) |
|
|
|
@ -482,7 +486,7 @@ export function useViewFilters(
|
|
|
|
|
|
|
|
|
|
const index = filters.value.length - 1 |
|
|
|
|
|
|
|
|
|
await saveOrUpdate(filters.value[index], index, true) |
|
|
|
|
await saveOrUpdate(filters.value[index], index) |
|
|
|
|
|
|
|
|
|
lastFilters.value = clone(filters.value) |
|
|
|
|
|
|
|
|
|