Browse Source

fix(nc-gui): sorting & filtering in kanban shared view

pull/3818/head
Wing-Kam Wong 2 years ago
parent
commit
6e992d6072
  1. 51
      packages/nc-gui/composables/useKanbanViewData.ts

51
packages/nc-gui/composables/useKanbanViewData.ts

@ -22,7 +22,7 @@ export function useKanbanViewData(
const { project } = useProject() const { project } = useProject()
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const { sorts, nestedFilters } = useSmartsheetStoreOrThrow() const { sorts, nestedFilters } = useSmartsheetStoreOrThrow()
const { sharedView, sorts: sharedViewSorts, nestedFilters: sharedViewNestedFilters } = useSharedView() const { fetchSharedViewData } = useSharedView()
const { isUIAllowed } = useUIPermission() const { isUIAllowed } = useUIPermission()
const isPublic = inject(IsPublicInj, ref(false)) const isPublic = inject(IsPublicInj, ref(false))
@ -87,27 +87,11 @@ export function useKanbanViewData(
const where = const where =
option.title === 'uncategorized' ? `(${groupingField.value},is,null)` : `(${groupingField.value},eq,${option.title})` option.title === 'uncategorized' ? `(${groupingField.value},is,null)` : `(${groupingField.value},eq,${option.title})`
let response const response = !isPublic.value
? await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!, {
if (isPublic.value && sharedView.value) {
response = (
await $api.public.dataList(
sharedView.value.uuid!,
{
where,
} as any,
{
headers: {
'xc-password': password.value,
},
},
)
).data
} else {
response = await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!, {
where, where,
}) })
} : await fetchSharedViewData()
formattedData.value[option.title!] = formatData(response.list) formattedData.value[option.title!] = formatData(response.list)
countByStack.value[option.title!] = response.pageInfo.totalRows || 0 countByStack.value[option.title!] = response.pageInfo.totalRows || 0
@ -121,33 +105,16 @@ export function useKanbanViewData(
if (stackTitle === 'uncategorized') { if (stackTitle === 'uncategorized') {
where = `(${groupingField.value},is,null)` where = `(${groupingField.value},is,null)`
} }
let response const response = !isPublic.value
? await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!, {
if (isPublic.value && sharedView.value) {
response = (
await $api.public.dataList(
sharedView.value.uuid!,
{
...params,
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sharedViewSorts.value) }),
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(sharedViewNestedFilters.value) }),
where,
} as any,
{
headers: {
'xc-password': password.value,
},
},
)
).data
} else {
response = await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!, {
...params, ...params,
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }), ...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }),
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), ...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }),
where, where,
}) })
} : // TODO: check this
await fetchSharedViewData()
formattedData.value[stackTitle] = [...formattedData.value[stackTitle], ...formatData(response.list)] formattedData.value[stackTitle] = [...formattedData.value[stackTitle], ...formatData(response.list)]
} }

Loading…
Cancel
Save