diff --git a/packages/nc-gui/composables/useViewData.ts b/packages/nc-gui/composables/useViewData.ts index 9f38e79159..bc32edd228 100644 --- a/packages/nc-gui/composables/useViewData.ts +++ b/packages/nc-gui/composables/useViewData.ts @@ -2,6 +2,7 @@ import type { Api, ColumnType, FormType, GalleryType, KanbanType, PaginatedType, import type { ComputedRef, Ref } from 'vue' import { message } from 'ant-design-vue' import { useI18n } from 'vue-i18n' +import { ViewTypes } from 'nocodb-sdk' import { useNuxtApp } from '#app' import { IsPublicInj, @@ -21,6 +22,22 @@ const formatData = (list: Record[]) => rowMeta: {}, })) +const formatKanbanData = (list: Record[]) => + list.reduce((acc: any, obj: any) => { + // TODO: grouping field + const groupingFeild = 'singleSelect2' + const key = obj[groupingFeild] + if (!acc[key]) { + acc[key] = [] + } + acc[key].push({ + row: { ...obj }, + oldRow: { ...obj }, + rowMeta: {}, + }) + return acc + }, {}) + export interface Row { row: Record oldRow: Record @@ -50,6 +67,7 @@ export function useViewData( // todo: missing properties on FormType (success_msg, show_blank_form, const formViewData = ref() const formattedData = ref([]) + const formattedKanbanData = ref>() const isPublic = inject(IsPublicInj, ref(false)) const { project, isSharedBase } = useProject() @@ -172,6 +190,9 @@ export function useViewData( where: where?.value, }) : await fetchSharedViewData() + if (viewMeta?.value.type === ViewTypes.KANBAN) { + formattedKanbanData.value = formatKanbanData(response.list) + } formattedData.value = formatData(response.list) paginationData.value = response.pageInfo await loadAggCommentsCount() @@ -395,6 +416,7 @@ export function useViewData( paginationData, queryParams, formattedData, + formattedKanbanData, insertRow, updateRowProperty, changePage,