|
|
@ -74,6 +74,11 @@ export function useMultiSelect( |
|
|
|
const columnObj = unref(fields)[cpCol] |
|
|
|
const columnObj = unref(fields)[cpCol] |
|
|
|
|
|
|
|
|
|
|
|
let textToCopy = (columnObj.title && rowObj.row[columnObj.title]) || '' |
|
|
|
let textToCopy = (columnObj.title && rowObj.row[columnObj.title]) || '' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (columnObj.uidt === UITypes.Checkbox) { |
|
|
|
|
|
|
|
textToCopy = !!textToCopy |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (typeof textToCopy === 'object') { |
|
|
|
if (typeof textToCopy === 'object') { |
|
|
|
textToCopy = JSON.stringify(textToCopy) |
|
|
|
textToCopy = JSON.stringify(textToCopy) |
|
|
|
} |
|
|
|
} |
|
|
@ -236,103 +241,102 @@ export function useMultiSelect( |
|
|
|
editEnabled.value = false |
|
|
|
editEnabled.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
break |
|
|
|
break |
|
|
|
default: |
|
|
|
default: { |
|
|
|
{ |
|
|
|
const rowObj = unref(data)[selectedCell.row] |
|
|
|
const rowObj = unref(data)[selectedCell.row] |
|
|
|
|
|
|
|
|
|
|
|
const columnObj = unref(fields)[selectedCell.col] |
|
|
|
const columnObj = unref(fields)[selectedCell.col] |
|
|
|
|
|
|
|
|
|
|
|
if ((!unref(editEnabled) && e.metaKey) || e.ctrlKey) { |
|
|
|
if ((!unref(editEnabled) && e.metaKey) || e.ctrlKey) { |
|
|
|
switch (e.keyCode) { |
|
|
|
switch (e.keyCode) { |
|
|
|
// copy - ctrl/cmd +c
|
|
|
|
// copy - ctrl/cmd +c
|
|
|
|
case 67: |
|
|
|
case 67: |
|
|
|
// set clipboard context only if single cell selected
|
|
|
|
// set clipboard context only if single cell selected
|
|
|
|
if (rowObj.row[columnObj.title!]) { |
|
|
|
if (rowObj.row[columnObj.title!]) { |
|
|
|
clipboardContext = { |
|
|
|
clipboardContext = { |
|
|
|
value: rowObj.row[columnObj.title!], |
|
|
|
value: rowObj.row[columnObj.title!], |
|
|
|
uidt: columnObj.uidt as UITypes, |
|
|
|
uidt: columnObj.uidt as UITypes, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
clipboardContext = null |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
await copyValue() |
|
|
|
} else { |
|
|
|
break |
|
|
|
clipboardContext = null |
|
|
|
case 86: |
|
|
|
} |
|
|
|
try { |
|
|
|
await copyValue() |
|
|
|
// handle belongs to column
|
|
|
|
break |
|
|
|
if ( |
|
|
|
case 86: |
|
|
|
columnObj.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
try { |
|
|
|
(columnObj.colOptions as LinkToAnotherRecordType)?.type === RelationTypes.BELONGS_TO |
|
|
|
// handle belongs to column
|
|
|
|
) { |
|
|
|
if ( |
|
|
|
if (!clipboardContext.value || typeof clipboardContext.value !== 'object') { |
|
|
|
columnObj.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
return message.info('Invalid data') |
|
|
|
(columnObj.colOptions as LinkToAnotherRecordType)?.type === RelationTypes.BELONGS_TO |
|
|
|
} |
|
|
|
) { |
|
|
|
rowObj.row[columnObj.title!] = convertCellData( |
|
|
|
if (!clipboardContext.value || typeof clipboardContext.value !== 'object') { |
|
|
|
{ |
|
|
|
return message.info('Invalid data') |
|
|
|
value: clipboardContext.value, |
|
|
|
|
|
|
|
from: clipboardContext.uidt, |
|
|
|
|
|
|
|
to: columnObj.uidt as UITypes, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
isMysql.value, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
e.preventDefault() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const foreignKeyColumn: ColumnType = meta.value?.columns.find( |
|
|
|
|
|
|
|
(column: ColumnType) => column.id === (columnObj.colOptions as LinkToAnotherRecordType)?.fk_child_column_id, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const relatedTableMeta = await getMeta((columnObj.colOptions as LinkToAnotherRecordType).fk_related_model_id!) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rowObj.row[foreignKeyColumn.title!] = extractPkFromRow( |
|
|
|
|
|
|
|
clipboardContext.value, |
|
|
|
|
|
|
|
(relatedTableMeta as any)!.columns!, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await syncCellData?.({ ...selectedCell, updatedColumnTitle: foreignKeyColumn.title }) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
rowObj.row[columnObj.title!] = convertCellData( |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
value: clipboardContext.value, |
|
|
|
|
|
|
|
from: clipboardContext.uidt, |
|
|
|
|
|
|
|
to: columnObj.uidt as UITypes, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
isMysql.value, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
e.preventDefault() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const foreignKeyColumn: ColumnType = meta.value?.columns.find( |
|
|
|
|
|
|
|
(column: ColumnType) => column.id === (columnObj.colOptions as LinkToAnotherRecordType)?.fk_child_column_id, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const relatedTableMeta = await getMeta((columnObj.colOptions as LinkToAnotherRecordType).fk_related_model_id!) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rowObj.row[foreignKeyColumn.title!] = extractPkFromRow( |
|
|
|
|
|
|
|
clipboardContext.value, |
|
|
|
|
|
|
|
(relatedTableMeta as any)!.columns!, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await syncCellData?.({ ...selectedCell, updatedColumnTitle: foreignKeyColumn.title }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// if it's a virtual column excluding belongs to cell type skip paste
|
|
|
|
// if it's a virtual column excluding belongs to cell type skip paste
|
|
|
|
if (isVirtualCol(columnObj)) { |
|
|
|
if (isVirtualCol(columnObj)) { |
|
|
|
return message.info(t('msg.info.notSupported')) |
|
|
|
return message.info(t('msg.info.notSupported')) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (clipboardContext) { |
|
|
|
if (clipboardContext) { |
|
|
|
rowObj.row[columnObj.title!] = convertCellData( |
|
|
|
rowObj.row[columnObj.title!] = convertCellData( |
|
|
|
{ |
|
|
|
{ |
|
|
|
value: clipboardContext.value, |
|
|
|
value: clipboardContext.value, |
|
|
|
from: clipboardContext.uidt, |
|
|
|
from: clipboardContext.uidt, |
|
|
|
to: columnObj.uidt as UITypes, |
|
|
|
to: columnObj.uidt as UITypes, |
|
|
|
}, |
|
|
|
}, |
|
|
|
isMysql.value, |
|
|
|
isMysql.value, |
|
|
|
) |
|
|
|
) |
|
|
|
e.preventDefault() |
|
|
|
e.preventDefault() |
|
|
|
syncCellData?.(selectedCell) |
|
|
|
syncCellData?.(selectedCell) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
clearCell(selectedCell as { row: number; col: number }, true) |
|
|
|
clearCell(selectedCell as { row: number; col: number }, true) |
|
|
|
makeEditable(rowObj, columnObj) |
|
|
|
makeEditable(rowObj, columnObj) |
|
|
|
} |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
message.error(await extractSdkResponseErrorMsg(error)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
message.error(await extractSdkResponseErrorMsg(error)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (unref(editEnabled) || e.ctrlKey || e.altKey || e.metaKey) { |
|
|
|
if (unref(editEnabled) || e.ctrlKey || e.altKey || e.metaKey) { |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** on letter key press make cell editable and empty */ |
|
|
|
/** on letter key press make cell editable and empty */ |
|
|
|
if (e.key.length === 1) { |
|
|
|
if (e.key.length === 1) { |
|
|
|
if (!unref(isPkAvail) && !rowObj.rowMeta.new) { |
|
|
|
if (!unref(isPkAvail) && !rowObj.rowMeta.new) { |
|
|
|
// Update not allowed for table which doesn't have primary Key
|
|
|
|
// Update not allowed for table which doesn't have primary Key
|
|
|
|
return message.info(t('msg.info.updateNotAllowedWithoutPK')) |
|
|
|
return message.info(t('msg.info.updateNotAllowedWithoutPK')) |
|
|
|
} |
|
|
|
} |
|
|
|
if (makeEditable(rowObj, columnObj) && columnObj.title) { |
|
|
|
if (makeEditable(rowObj, columnObj) && columnObj.title) { |
|
|
|
rowObj.row[columnObj.title] = '' |
|
|
|
rowObj.row[columnObj.title] = '' |
|
|
|
} |
|
|
|
|
|
|
|
// editEnabled = true
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// editEnabled = true
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|