Browse Source

fix(nc-gui): kanban attachment path logic

pull/4931/head
Wing-Kam Wong 2 years ago
parent
commit
d36e16ba57
  1. 27
      packages/nc-gui/composables/useKanbanViewStore.ts

27
packages/nc-gui/composables/useKanbanViewStore.ts

@ -1,5 +1,15 @@
import type { ComputedRef, Ref } from 'vue' import type { ComputedRef, Ref } from 'vue'
import type { Api, ColumnType, KanbanType, SelectOptionType, SelectOptionsType, TableType, ViewType } from 'nocodb-sdk' import type {
Api,
AttachmentType,
ColumnType,
KanbanType,
SelectOptionType,
SelectOptionsType,
TableType,
ViewType,
} from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk'
import type { Row } from '~/lib' import type { Row } from '~/lib'
import { import {
IsPublicInj, IsPublicInj,
@ -14,6 +24,7 @@ import {
provide, provide,
ref, ref,
useApi, useApi,
useGlobal,
useI18n, useI18n,
useInjectionState, useInjectionState,
useNuxtApp, useNuxtApp,
@ -21,9 +32,7 @@ import {
useSharedView, useSharedView,
useSmartsheetStoreOrThrow, useSmartsheetStoreOrThrow,
useUIPermission, useUIPermission,
useGlobal,
} from '#imports' } from '#imports'
import { AttachmentType, UITypes } from 'nocodb-sdk'
type GroupingFieldColOptionsType = SelectOptionType & { collapsed: boolean } type GroupingFieldColOptionsType = SelectOptionType & { collapsed: boolean }
@ -138,15 +147,15 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState(
formattedData.value = new Map<string | null, Row[]>() formattedData.value = new Map<string | null, Row[]>()
countByStack.value = new Map<string | null, number>() countByStack.value = new Map<string | null, number>()
let res let groupData
if (isPublic.value) { if (isPublic.value) {
res = await fetchSharedViewGroupedData(groupingFieldColumn!.value!.id!, { groupData = await fetchSharedViewGroupedData(groupingFieldColumn!.value!.id!, {
sortsArr: sorts.value, sortsArr: sorts.value,
filtersArr: nestedFilters.value, filtersArr: nestedFilters.value,
}) })
} else { } else {
res = await api.dbViewRow.groupedDataList( groupData = await api.dbViewRow.groupedDataList(
'noco', 'noco',
project.value.id!, project.value.id!,
meta.value!.id!, meta.value!.id!,
@ -157,10 +166,12 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState(
) )
} }
let records = [] for (const data of groupData) {
for (const data of res) { const records = []
const key = data.key const key = data.key
// TODO: optimize // TODO: optimize
// reconstruct the url
// See /packages/nocodb/src/lib/version-upgrader/ncAttachmentUpgrader.ts for the details
for (const record of data.value.list) { for (const record of data.value.list) {
for (const attachmentColumn of attachmentColumns.value) { for (const attachmentColumn of attachmentColumns.value) {
const oldAttachment = JSON.parse(record[attachmentColumn!]) const oldAttachment = JSON.parse(record[attachmentColumn!])

Loading…
Cancel
Save