|
|
@ -3,7 +3,7 @@ import { computed } from 'vue' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
import type { MaybeRef } from '@vueuse/core' |
|
|
|
import type { MaybeRef } from '@vueuse/core' |
|
|
|
import type { ColumnType, LinkToAnotherRecordType, TableType, UserFieldRecordType, ViewType } from 'nocodb-sdk' |
|
|
|
import type { ColumnType, LinkToAnotherRecordType, TableType, UserFieldRecordType, ViewType } from 'nocodb-sdk' |
|
|
|
import { RelationTypes, UITypes, dateFormats, isDateMonthFormat, isSystemColumn, isVirtualCol, timeFormats } from 'nocodb-sdk' |
|
|
|
import { UITypes, dateFormats, isDateMonthFormat, isSystemColumn, isVirtualCol, timeFormats } from 'nocodb-sdk' |
|
|
|
import { parse } from 'papaparse' |
|
|
|
import { parse } from 'papaparse' |
|
|
|
import type { Cell } from './cellRange' |
|
|
|
import type { Cell } from './cellRange' |
|
|
|
import { CellRange } from './cellRange' |
|
|
|
import { CellRange } from './cellRange' |
|
|
@ -12,9 +12,11 @@ import type { Nullable, Row } from '#imports' |
|
|
|
import { |
|
|
|
import { |
|
|
|
extractPkFromRow, |
|
|
|
extractPkFromRow, |
|
|
|
extractSdkResponseErrorMsg, |
|
|
|
extractSdkResponseErrorMsg, |
|
|
|
|
|
|
|
isBt, |
|
|
|
isDrawerOrModalExist, |
|
|
|
isDrawerOrModalExist, |
|
|
|
isExpandedCellInputExist, |
|
|
|
isExpandedCellInputExist, |
|
|
|
isMac, |
|
|
|
isMac, |
|
|
|
|
|
|
|
isMm, |
|
|
|
isTypableInputColumn, |
|
|
|
isTypableInputColumn, |
|
|
|
message, |
|
|
|
message, |
|
|
|
parseProp, |
|
|
|
parseProp, |
|
|
@ -136,10 +138,7 @@ export function useMultiSelect( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if (isBt(columnObj)) { |
|
|
|
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
|
|
|
|
// 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, |
|
|
|
fk_related_model_id: (columnObj.colOptions as LinkToAnotherRecordType).fk_related_model_id, |
|
|
@ -147,10 +146,7 @@ export function useMultiSelect( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if (isMm(columnObj)) { |
|
|
|
columnObj.uidt === UITypes.Links && |
|
|
|
|
|
|
|
(columnObj.colOptions as LinkToAnotherRecordType).type === RelationTypes.MANY_TO_MANY |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
textToCopy = { |
|
|
|
textToCopy = { |
|
|
|
rowId: extractPkFromRow(rowObj.row, meta.value?.columns as ColumnType[]), |
|
|
|
rowId: extractPkFromRow(rowObj.row, meta.value?.columns as ColumnType[]), |
|
|
|
columnId: columnObj.id, |
|
|
|
columnId: columnObj.id, |
|
|
@ -878,10 +874,7 @@ export function useMultiSelect( |
|
|
|
const columnObj = unref(fields)[activeCell.col] |
|
|
|
const columnObj = unref(fields)[activeCell.col] |
|
|
|
|
|
|
|
|
|
|
|
// handle belongs to column
|
|
|
|
// handle belongs to column
|
|
|
|
if ( |
|
|
|
if (isBt(columnObj)) { |
|
|
|
columnObj.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
|
|
|
|
(columnObj.colOptions as LinkToAnotherRecordType)?.type === RelationTypes.BELONGS_TO |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
const pasteVal = convertCellData( |
|
|
|
const pasteVal = convertCellData( |
|
|
|
{ |
|
|
|
{ |
|
|
|
value: clipboardData, |
|
|
|
value: clipboardData, |
|
|
@ -911,10 +904,7 @@ export function useMultiSelect( |
|
|
|
return await syncCellData?.({ ...activeCell, updatedColumnTitle: foreignKeyColumn.title }) |
|
|
|
return await syncCellData?.({ ...activeCell, updatedColumnTitle: foreignKeyColumn.title }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if (isMm(columnObj)) { |
|
|
|
columnObj.uidt === UITypes.Links && |
|
|
|
|
|
|
|
(columnObj.colOptions as LinkToAnotherRecordType)?.type === RelationTypes.MANY_TO_MANY |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
const pasteVal = convertCellData( |
|
|
|
const pasteVal = convertCellData( |
|
|
|
{ |
|
|
|
{ |
|
|
|
value: clipboardData, |
|
|
|
value: clipboardData, |
|
|
@ -937,7 +927,10 @@ export function useMultiSelect( |
|
|
|
let result |
|
|
|
let result |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
result = await api.dbDataTableRow.nestedListCopyPaste(meta.value?.id as string, columnObj.id as string, [ |
|
|
|
result = await api.dbDataTableRow.nestedListCopyPasteOrDeleteAll( |
|
|
|
|
|
|
|
meta.value?.id as string, |
|
|
|
|
|
|
|
columnObj.id as string, |
|
|
|
|
|
|
|
[ |
|
|
|
{ |
|
|
|
{ |
|
|
|
operation: 'copy', |
|
|
|
operation: 'copy', |
|
|
|
rowId: pasteVal.rowId, |
|
|
|
rowId: pasteVal.rowId, |
|
|
@ -947,11 +940,13 @@ export function useMultiSelect( |
|
|
|
{ |
|
|
|
{ |
|
|
|
operation: 'paste', |
|
|
|
operation: 'paste', |
|
|
|
rowId: pasteRowPk, |
|
|
|
rowId: pasteRowPk, |
|
|
|
columnId: pasteVal.columnId, |
|
|
|
columnId: columnObj.id as string, |
|
|
|
fk_related_model_id: |
|
|
|
fk_related_model_id: |
|
|
|
(columnObj.colOptions as LinkToAnotherRecordType).fk_related_model_id || pasteVal.fk_related_model_id, |
|
|
|
(columnObj.colOptions as LinkToAnotherRecordType).fk_related_model_id || pasteVal.fk_related_model_id, |
|
|
|
}, |
|
|
|
}, |
|
|
|
]) |
|
|
|
], |
|
|
|
|
|
|
|
{ viewId: activeView?.value?.id }, |
|
|
|
|
|
|
|
) |
|
|
|
} catch { |
|
|
|
} catch { |
|
|
|
rowObj.row[columnObj.title!] = oldCellValue |
|
|
|
rowObj.row[columnObj.title!] = oldCellValue |
|
|
|
return |
|
|
|
return |
|
|
@ -970,17 +965,23 @@ export function useMultiSelect( |
|
|
|
pasteRowPk: string, |
|
|
|
pasteRowPk: string, |
|
|
|
result: { link: any[]; unlink: any[] }, |
|
|
|
result: { link: any[]; unlink: any[] }, |
|
|
|
value: number, |
|
|
|
value: number, |
|
|
|
activeCell: Nullable<Cell>, |
|
|
|
activeCell: Cell, |
|
|
|
) => { |
|
|
|
) => { |
|
|
|
|
|
|
|
const rowObj = unref(data)[activeCell.row] |
|
|
|
|
|
|
|
const columnObj = unref(fields)[activeCell.col] |
|
|
|
|
|
|
|
|
|
|
|
await Promise.all([ |
|
|
|
await Promise.all([ |
|
|
|
result.link.length && |
|
|
|
result.link.length && |
|
|
|
api.dbDataTableRow.nestedLink(tableId, columnId, encodeURIComponent(pasteRowPk), result.link), |
|
|
|
api.dbDataTableRow.nestedLink(tableId, columnId, encodeURIComponent(pasteRowPk), result.link, { |
|
|
|
|
|
|
|
viewId: activeView?.value?.id, |
|
|
|
|
|
|
|
}), |
|
|
|
result.unlink.length && |
|
|
|
result.unlink.length && |
|
|
|
api.dbDataTableRow.nestedUnlink( |
|
|
|
api.dbDataTableRow.nestedUnlink( |
|
|
|
meta.value?.id as string, |
|
|
|
meta.value?.id as string, |
|
|
|
columnObj.id as string, |
|
|
|
columnObj.id as string, |
|
|
|
encodeURIComponent(pasteRowPk), |
|
|
|
encodeURIComponent(pasteRowPk), |
|
|
|
result.unlink, |
|
|
|
result.unlink, |
|
|
|
|
|
|
|
{ viewId: activeView?.value?.id }, |
|
|
|
), |
|
|
|
), |
|
|
|
]) |
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
@ -997,8 +998,11 @@ export function useMultiSelect( |
|
|
|
pasteRowPk: string, |
|
|
|
pasteRowPk: string, |
|
|
|
result: { link: any[]; unlink: any[] }, |
|
|
|
result: { link: any[]; unlink: any[] }, |
|
|
|
value: number, |
|
|
|
value: number, |
|
|
|
activeCell: Nullable<Cell>, |
|
|
|
activeCell: Cell, |
|
|
|
) => { |
|
|
|
) => { |
|
|
|
|
|
|
|
const rowObj = unref(data)[activeCell.row] |
|
|
|
|
|
|
|
const columnObj = unref(fields)[activeCell.col] |
|
|
|
|
|
|
|
|
|
|
|
await Promise.all([ |
|
|
|
await Promise.all([ |
|
|
|
result.unlink.length && |
|
|
|
result.unlink.length && |
|
|
|
api.dbDataTableRow.nestedLink(tableId, columnId, encodeURIComponent(pasteRowPk), result.unlink), |
|
|
|
api.dbDataTableRow.nestedLink(tableId, columnId, encodeURIComponent(pasteRowPk), result.unlink), |
|
|
|