Browse Source

feat(nc-gui): handle empty grouping field column options

pull/3818/head
Wing-Kam Wong 2 years ago
parent
commit
d88e877233
  1. 8
      packages/nc-gui/composables/useViewData.ts

8
packages/nc-gui/composables/useViewData.ts

@ -63,9 +63,11 @@ export function useViewData(
const formatKanbanData = (list: Record<string, any>[]) => { const formatKanbanData = (list: Record<string, any>[]) => {
const groupingField = 'singleSelect2' const groupingField = 'singleSelect2'
const groupingFieldColumn = meta?.value?.columns?.filter((f) => f.title === groupingField)[0] as Record<string, any> const groupingFieldColumn = meta?.value?.columns?.filter((f) => f.title === groupingField)[0] as Record<string, any>
const groupingFieldColumnOptions = [...groupingFieldColumn?.colOptions?.options, { title: 'Uncategorized', order: 0 }].sort( // TODO: sort by kanban meta
(a: Record<string, any>, b: Record<string, any>) => a.order - b.order, const groupingFieldColumnOptions = [
) ...(groupingFieldColumn?.colOptions?.options ?? []),
{ title: 'Uncategorized', order: 0 },
].sort((a: Record<string, any>, b: Record<string, any>) => a.order - b.order)
const initialAcc = groupingFieldColumnOptions.reduce((acc: any, obj: any) => { const initialAcc = groupingFieldColumnOptions.reduce((acc: any, obj: any) => {
if (!acc[obj.title]) { if (!acc[obj.title]) {
acc[obj.title] = [] acc[obj.title] = []

Loading…
Cancel
Save