|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import type { MaybeRef } from '@vueuse/core' |
|
|
|
|
import { UITypes } from 'nocodb-sdk' |
|
|
|
|
import { message, reactive, unref, useCopy, useEventListener, useI18n, ref } from '#imports' |
|
|
|
|
import { message, reactive, ref, unref, useCopy, useEventListener, useI18n } from '#imports' |
|
|
|
|
|
|
|
|
|
interface SelectedBlock { |
|
|
|
|
row: number | null |
|
|
|
@ -227,60 +227,61 @@ export function useMultiSelect(
|
|
|
|
|
editEnabled.value = false |
|
|
|
|
} |
|
|
|
|
break |
|
|
|
|
default: { |
|
|
|
|
const rowObj = unref(data)[selected.row] |
|
|
|
|
default: |
|
|
|
|
{ |
|
|
|
|
const rowObj = unref(data)[selected.row] |
|
|
|
|
|
|
|
|
|
const columnObj = unref(fields)[selected.col] |
|
|
|
|
const columnObj = unref(fields)[selected.col] |
|
|
|
|
|
|
|
|
|
let cptext = '' // variable for save the text to be copy
|
|
|
|
|
let cptext = '' // variable for save the text to be copy
|
|
|
|
|
|
|
|
|
|
if (!isNaN(rangeRows.minRow) && !isNaN(rangeRows.maxRow) && !isNaN(rangeRows.minCol) && !isNaN(rangeRows.maxCol)) { |
|
|
|
|
const cprows = unref(data).slice(rangeRows.minRow, rangeRows.maxRow + 1) // slice the selected rows for copy
|
|
|
|
|
if (!isNaN(rangeRows.minRow) && !isNaN(rangeRows.maxRow) && !isNaN(rangeRows.minCol) && !isNaN(rangeRows.maxCol)) { |
|
|
|
|
const cprows = unref(data).slice(rangeRows.minRow, rangeRows.maxRow + 1) // slice the selected rows for copy
|
|
|
|
|
|
|
|
|
|
const cpcols = unref(fields).slice(rangeRows.minCol, rangeRows.maxCol + 1) // slice the selected cols for copy
|
|
|
|
|
const cpcols = unref(fields).slice(rangeRows.minCol, rangeRows.maxCol + 1) // slice the selected cols for copy
|
|
|
|
|
|
|
|
|
|
cprows.forEach((row) => { |
|
|
|
|
cpcols.forEach((col) => { |
|
|
|
|
// todo: JSON stringify the attachment cell and LTAR contents for copy
|
|
|
|
|
// filter attachment cells and LATR cells from copy
|
|
|
|
|
if (col.uidt !== UITypes.Attachment && col.uidt !== UITypes.LinkToAnotherRecord) { |
|
|
|
|
cptext = `${cptext} ${row.row[col.title]} \t` |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
cptext = `${cptext.trim()}\n` |
|
|
|
|
}) |
|
|
|
|
cprows.forEach((row) => { |
|
|
|
|
cpcols.forEach((col) => { |
|
|
|
|
// todo: JSON stringify the attachment cell and LTAR contents for copy
|
|
|
|
|
// filter attachment cells and LATR cells from copy
|
|
|
|
|
if (col.uidt !== UITypes.Attachment && col.uidt !== UITypes.LinkToAnotherRecord) { |
|
|
|
|
cptext = `${cptext} ${row.row[col.title]} \t` |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
cptext.trim() |
|
|
|
|
} else { |
|
|
|
|
cptext = rowObj.row[columnObj.title] || '' |
|
|
|
|
} |
|
|
|
|
cptext = `${cptext.trim()}\n` |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
if ((!unref(editEnabled) && e.metaKey) || e.ctrlKey) { |
|
|
|
|
switch (e.keyCode) { |
|
|
|
|
// copy - ctrl/cmd +c
|
|
|
|
|
case 67: |
|
|
|
|
await copy(cptext) |
|
|
|
|
break |
|
|
|
|
cptext.trim() |
|
|
|
|
} else { |
|
|
|
|
cptext = rowObj.row[columnObj.title] || '' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (unref(editEnabled) || e.ctrlKey || e.altKey || e.metaKey) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if ((!unref(editEnabled) && e.metaKey) || e.ctrlKey) { |
|
|
|
|
switch (e.keyCode) { |
|
|
|
|
// copy - ctrl/cmd +c
|
|
|
|
|
case 67: |
|
|
|
|
await copy(cptext) |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** on letter key press make cell editable and empty */ |
|
|
|
|
if (e.key.length === 1) { |
|
|
|
|
if (!unref(isPkAvail) && !rowObj.rowMeta.new) { |
|
|
|
|
// Update not allowed for table which doesn't have primary Key
|
|
|
|
|
return message.info(t('msg.info.updateNotAllowedWithoutPK')) |
|
|
|
|
if (unref(editEnabled) || e.ctrlKey || e.altKey || e.metaKey) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if (makeEditable(rowObj, columnObj)) { |
|
|
|
|
rowObj.row[columnObj.title] = '' |
|
|
|
|
|
|
|
|
|
/** on letter key press make cell editable and empty */ |
|
|
|
|
if (e.key.length === 1) { |
|
|
|
|
if (!unref(isPkAvail) && !rowObj.rowMeta.new) { |
|
|
|
|
// Update not allowed for table which doesn't have primary Key
|
|
|
|
|
return message.info(t('msg.info.updateNotAllowedWithoutPK')) |
|
|
|
|
} |
|
|
|
|
if (makeEditable(rowObj, columnObj)) { |
|
|
|
|
rowObj.row[columnObj.title] = '' |
|
|
|
|
} |
|
|
|
|
// editEnabled = true
|
|
|
|
|
} |
|
|
|
|
// editEnabled = true
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|