Browse Source

fix: paste picks up ID from the copy source record ID & not the link

pull/7558/head
Ramesh Mane 9 months ago
parent
commit
09ac06d073
  1. 10
      packages/nc-gui/composables/useMultiSelect/index.ts

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

@ -27,6 +27,7 @@ import {
useEventListener, useEventListener,
useGlobal, useGlobal,
useI18n, useI18n,
useMetas,
useUndoRedo, useUndoRedo,
} from '#imports' } from '#imports'
@ -58,6 +59,8 @@ export function useMultiSelect(
const { copy } = useCopy() const { copy } = useCopy()
const { getMeta } = useMetas()
const { appInfo } = useGlobal() const { appInfo } = useGlobal()
const { isMysql, isPg } = useBase() const { isMysql, isPg } = useBase()
@ -139,7 +142,6 @@ export function useMultiSelect(
) { ) {
// fk_related_model_id is used to prevent paste operation in different fk_related_model_id cell // fk_related_model_id is used to prevent paste operation in different fk_related_model_id cell
textToCopy = { textToCopy = {
rowId: extractPkFromRow(rowObj.row, meta.value?.columns as ColumnType[]),
fk_related_model_id: (columnObj.colOptions as LinkToAnotherRecordType).fk_related_model_id, fk_related_model_id: (columnObj.colOptions as LinkToAnotherRecordType).fk_related_model_id,
value: textToCopy || null, value: textToCopy || null,
} }
@ -898,9 +900,13 @@ export function useMultiSelect(
if (!foreignKeyColumn) return if (!foreignKeyColumn) return
const relatedTableMeta = await getMeta((columnObj.colOptions as LinkToAnotherRecordType).fk_related_model_id!)
rowObj.row[columnObj.title!] = pasteVal?.value rowObj.row[columnObj.title!] = pasteVal?.value
rowObj.row[foreignKeyColumn.title!] = pasteVal?.value ? pasteVal.rowId : null rowObj.row[foreignKeyColumn.title!] = pasteVal?.value
? extractPkFromRow(pasteVal.value, (relatedTableMeta as any)!.columns!)
: null
return await syncCellData?.({ ...activeCell, updatedColumnTitle: foreignKeyColumn.title }) return await syncCellData?.({ ...activeCell, updatedColumnTitle: foreignKeyColumn.title })
} }

Loading…
Cancel
Save