Browse Source

fix(nc-gui): PR review changes #2215

pull/7491/head
Ramesh Mane 10 months ago
parent
commit
6865243cf7
  1. 8
      packages/nc-gui/composables/useMultiSelect/convertCellData.ts
  2. 12
      packages/nc-gui/composables/useMultiSelect/index.ts

8
packages/nc-gui/composables/useMultiSelect/convertCellData.ts

@ -5,11 +5,11 @@ import type { AppInfo } from '~/composables/useGlobal'
import { parseProp } from '#imports' import { parseProp } from '#imports'
export default function convertCellData( export default function convertCellData(
args: { to: UITypes; value: string; files?: FileList | File[]; oldFiles?: any[] | null; column: ColumnType; appInfo: AppInfo }, args: { to: UITypes; value: string; column: ColumnType; appInfo: AppInfo; files?: FileList | File[]; oldValue?: unknown },
isMysql = false, isMysql = false,
isMultiple = false, isMultiple = false,
) { ) {
const { to, value, files = [], oldFiles, column } = args const { to, value, column, files = [], oldValue } = args
const dateFormat = isMysql ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ' const dateFormat = isMysql ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ'
@ -113,8 +113,8 @@ export default function convertCellData(
} }
} }
case UITypes.Attachment: { case UITypes.Attachment: {
const parsedOldFiles = parseProp(oldFiles) const parsedOldValue = parseProp(oldValue)
const oldAttachments = parsedOldFiles && Array.isArray(parsedOldFiles) ? parsedOldFiles : [] const oldAttachments = parsedOldValue && Array.isArray(parsedOldValue) ? parsedOldValue : []
if (!value && !files.length) { if (!value && !files.length) {
if (oldAttachments.length) return undefined if (oldAttachments.length) return undefined

12
packages/nc-gui/composables/useMultiSelect/index.ts

@ -820,10 +820,10 @@ export function useMultiSelect(
{ {
// Repeat the clipboard data array if the matrix is smaller than the selection // Repeat the clipboard data array if the matrix is smaller than the selection
value: clipboardMatrix[i % clipboardMatrix.length][j], value: clipboardMatrix[i % clipboardMatrix.length][j],
oldFiles: pasteCol.uidt === UITypes.Attachment ? pasteRow.row[pasteCol.title!] : undefined,
to: pasteCol.uidt as UITypes, to: pasteCol.uidt as UITypes,
column: pasteCol, column: pasteCol,
appInfo: unref(appInfo), appInfo: unref(appInfo),
oldValue: pasteCol.uidt === UITypes.Attachment ? pasteRow.row[pasteCol.title!] : undefined,
}, },
isMysql(meta.value?.source_id), isMysql(meta.value?.source_id),
true, true,
@ -883,11 +883,11 @@ export function useMultiSelect(
const pasteValue = convertCellData( const pasteValue = convertCellData(
{ {
value: clipboardData, value: clipboardData,
files: columnObj.uidt === UITypes.Attachment && e.clipboardData?.files?.length ? e.clipboardData?.files : undefined,
oldFiles: rowObj.row[columnObj.title!],
to: columnObj.uidt as UITypes, to: columnObj.uidt as UITypes,
column: columnObj, column: columnObj,
appInfo: unref(appInfo), appInfo: unref(appInfo),
files: columnObj.uidt === UITypes.Attachment && e.clipboardData?.files?.length ? e.clipboardData?.files : undefined,
oldValue: rowObj.row[columnObj.title!],
}, },
isMysql(meta.value?.source_id), isMysql(meta.value?.source_id),
) )
@ -937,11 +937,11 @@ export function useMultiSelect(
const fileUploadPayload = convertCellData( const fileUploadPayload = convertCellData(
{ {
value: '', value: '',
files,
oldFiles: row.row[col.title],
to: col.uidt as UITypes, to: col.uidt as UITypes,
column: col, column: col,
appInfo: unref(appInfo), appInfo: unref(appInfo),
files,
oldValue: row.row[col.title],
}, },
isMysql(meta.value?.source_id), isMysql(meta.value?.source_id),
true, true,
@ -960,10 +960,10 @@ export function useMultiSelect(
pasteValue = convertCellData( pasteValue = convertCellData(
{ {
value: clipboardData, value: clipboardData,
oldFiles: row.row[col.title],
to: col.uidt as UITypes, to: col.uidt as UITypes,
column: col, column: col,
appInfo: unref(appInfo), appInfo: unref(appInfo),
oldValue: row.row[col.title],
}, },
isMysql(meta.value?.source_id), isMysql(meta.value?.source_id),
true, true,

Loading…
Cancel
Save