Browse Source

chore(gui): lint

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4514/head
Pranav C 2 years ago
parent
commit
b2317546f5
  1. 2
      packages/nc-gui/composables/useColumnCreateStore.ts
  2. 29
      packages/nc-gui/composables/useMultiSelect/index.ts

2
packages/nc-gui/composables/useColumnCreateStore.ts

@ -194,7 +194,7 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
const addOrUpdate = async (onSuccess: () => void, columnPosition?: Pick<ColumnReqType, 'column_order'>) => {
try {
if (!(await validate())) return
} catch (e) {
} catch (e: any) {
const errorMsgs = e.errorFields
?.map((e: any) => e.errors?.join(', '))
.filter(Boolean)

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

@ -3,11 +3,13 @@ import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk'
import { RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk'
import type { Cell } from './cellRange'
import { CellRange } from './cellRange'
import convertCellData from '~/composables/useMultiSelect/convertCellData'
import convertCellData from './convertCellData'
import type { Row } from '~/lib'
import {
copyTable,
extractPkFromRow,
extractSdkResponseErrorMsg,
isMac,
message,
reactive,
ref,
@ -18,7 +20,6 @@ import {
useMetas,
useProject,
} from '#imports'
import type { Row } from '~/lib'
/**
* Utility to help with multi-selecting rows/cells in the smartsheet
@ -247,7 +248,21 @@ export function useMultiSelect(
const columnObj = unref(fields)[selectedCell.col]
if ((!unref(editEnabled) && e.metaKey) || e.ctrlKey) {
if (
(!unref(editEnabled) ||
[
UITypes.DateTime,
UITypes.Date,
UITypes.Year,
UITypes.Time,
UITypes.Lookup,
UITypes.Rollup,
UITypes.Formula,
UITypes.Attachment,
UITypes.Checkbox,
].includes(columnObj.uidt as UITypes)) &&
(isMac() ? e.metaKey : e.ctrlKey)
) {
switch (e.keyCode) {
// copy - ctrl/cmd +c
case 67:
@ -269,7 +284,7 @@ export function useMultiSelect(
columnObj.uidt === UITypes.LinkToAnotherRecord &&
(columnObj.colOptions as LinkToAnotherRecordType)?.type === RelationTypes.BELONGS_TO
) {
if (!clipboardContext.value || typeof clipboardContext.value !== 'object') {
if (!clipboardContext || typeof clipboardContext.value !== 'object') {
return message.info('Invalid data')
}
rowObj.row[columnObj.title!] = convertCellData(
@ -282,12 +297,14 @@ export function useMultiSelect(
)
e.preventDefault()
const foreignKeyColumn: ColumnType = meta.value?.columns.find(
const foreignKeyColumn = 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!)
if (!foreignKeyColumn) return
rowObj.row[foreignKeyColumn.title!] = extractPkFromRow(
clipboardContext.value,
(relatedTableMeta as any)!.columns!,
@ -316,7 +333,7 @@ export function useMultiSelect(
clearCell(selectedCell as { row: number; col: number }, true)
makeEditable(rowObj, columnObj)
}
} catch (error) {
} catch (error: any) {
message.error(await extractSdkResponseErrorMsg(error))
}
}

Loading…
Cancel
Save