Browse Source

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

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

65
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) { where,
response = ( })
await $api.public.dataList( : await fetchSharedViewData()
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,
})
}
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) { ...params,
response = ( ...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }),
await $api.public.dataList( ...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }),
sharedView.value.uuid!, where,
{ })
...params, : // TODO: check this
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sharedViewSorts.value) }), await fetchSharedViewData()
...(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,
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }),
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }),
where,
})
}
formattedData.value[stackTitle] = [...formattedData.value[stackTitle], ...formatData(response.list)] formattedData.value[stackTitle] = [...formattedData.value[stackTitle], ...formatData(response.list)]
} }

Loading…
Cancel
Save