Browse Source

fix(gui): avoid clearing cell data if it's a non-typable column

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4556/head
Pranav C 2 years ago
parent
commit
701cf04083
  1. 20
      packages/nc-gui/composables/useMultiSelect/index.ts
  2. 31
      packages/nc-gui/utils/columnUtils.ts

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

@ -4,6 +4,7 @@ import { RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk'
import type { Cell } from './cellRange' import type { Cell } from './cellRange'
import { CellRange } from './cellRange' import { CellRange } from './cellRange'
import convertCellData from './convertCellData' import convertCellData from './convertCellData'
import { isTypableInputColumn } from '~/utils'
import type { Row } from '~/lib' import type { Row } from '~/lib'
import { import {
copyTable, copyTable,
@ -248,22 +249,7 @@ export function useMultiSelect(
const columnObj = unref(fields)[selectedCell.col] const columnObj = unref(fields)[selectedCell.col]
if ( if ((!unref(editEnabled) || !isTypableInputColumn(columnObj)) && (isMac() ? e.metaKey : e.ctrlKey)) {
(!unref(editEnabled) ||
[
UITypes.DateTime,
UITypes.Date,
UITypes.Year,
UITypes.Time,
UITypes.Lookup,
UITypes.Rollup,
UITypes.Formula,
UITypes.Attachment,
UITypes.Checkbox,
UITypes.Rating,
].includes(columnObj.uidt as UITypes)) &&
(isMac() ? e.metaKey : e.ctrlKey)
) {
switch (e.keyCode) { switch (e.keyCode) {
// copy - ctrl/cmd +c // copy - ctrl/cmd +c
case 67: case 67:
@ -350,7 +336,7 @@ export function useMultiSelect(
// 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 (isTypableInputColumn(columnObj) && makeEditable(rowObj, columnObj) && columnObj.title) {
rowObj.row[columnObj.title] = '' rowObj.row[columnObj.title] = ''
} }
// editEnabled = true // editEnabled = true

31
packages/nc-gui/utils/columnUtils.ts

@ -190,4 +190,33 @@ const getUniqueColumnName = (initName: string, columns: ColumnType[]) => {
return name return name
} }
export { uiTypes, getUIDTIcon, getUniqueColumnName, isColumnRequiredAndNull, isColumnRequired, isVirtualColRequired } const isTypableInputColumn = (colOrUidt: ColumnType | UITypes) => {
let uidt: UITypes;
if (typeof colOrUidt === 'object') {
uidt = colOrUidt.uidt as UITypes
} else {
uidt = colOrUidt
}
return [
UITypes.LongText,
UITypes.SingleLineText,
UITypes.Number,
UITypes.PhoneNumber,
UITypes.Email,
UITypes.Decimal,
UITypes.Currency,
UITypes.Percent,
UITypes.Duration,
UITypes.JSON,
].includes(uidt)
}
export {
uiTypes,
isTypableInputColumn,
getUIDTIcon,
getUniqueColumnName,
isColumnRequiredAndNull,
isColumnRequired,
isVirtualColRequired,
}

Loading…
Cancel
Save