fix(nc-gui): prevent paste bt cell value to different fk_related_model_id cell

This commit is contained in:
Ramesh Mane
2024-02-19 03:41:21 +00:00
parent b65240b6b2
commit aed6b95bc1
2 changed files with 24 additions and 7 deletions

View File

@@ -137,6 +137,15 @@ export function useMultiSelect(
}
}
if (
typeof textToCopy === 'object' &&
columnObj.uidt === UITypes.LinkToAnotherRecord &&
(columnObj.colOptions as LinkToAnotherRecordType).type === RelationTypes.BELONGS_TO
) {
// fk_related_model_id is used to prevent paste operation in different fk_related_model_id cell
textToCopy = { ...textToCopy, fk_related_model_id: (columnObj.colOptions as LinkToAnotherRecordType).fk_related_model_id }
}
if (typeof textToCopy === 'object') {
textToCopy = JSON.stringify(textToCopy)
} else {
@@ -871,10 +880,9 @@ export function useMultiSelect(
columnObj.uidt === UITypes.LinkToAnotherRecord &&
(columnObj.colOptions as LinkToAnotherRecordType)?.type === RelationTypes.BELONGS_TO
) {
const clipboardContext = JSON.parse(clipboardData!)
const pasteVal = convertCellData(
{
value: clipboardContext,
value: clipboardData,
to: columnObj.uidt as UITypes,
column: columnObj,
appInfo: unref(appInfo),
@@ -894,7 +902,7 @@ export function useMultiSelect(
if (!foreignKeyColumn) return
rowObj.row[foreignKeyColumn.title!] = extractPkFromRow(clipboardContext, (relatedTableMeta as any)!.columns!)
rowObj.row[foreignKeyColumn.title!] = extractPkFromRow(pasteVal, (relatedTableMeta as any)!.columns!)
return await syncCellData?.({ ...activeCell, updatedColumnTitle: foreignKeyColumn.title })
}