Browse Source

fix: show warning on paste or clear on not supported col

pull/7558/head
Ramesh Mane 9 months ago
parent
commit
71158bc6d7
  1. 7
      packages/nc-gui/components/smartsheet/Row.vue
  2. 27
      packages/nc-gui/components/smartsheet/grid/Table.vue
  3. 9
      packages/nc-gui/composables/useLTARStore.ts
  4. 12
      packages/nc-gui/composables/useMultiSelect/index.ts
  5. 2
      packages/nc-gui/composables/useSmartsheetRowStore.ts
  6. 2
      packages/nc-gui/composables/useViewSorts.ts
  7. 5
      packages/nc-gui/lang/en.json
  8. 2
      packages/nc-gui/utils/dataUtils.ts
  9. 1
      packages/nocodb/src/db/BaseModelSqlv2.ts

7
packages/nc-gui/components/smartsheet/Row.vue

@ -21,7 +21,10 @@ const currentRow = toRef(props, 'row')
const { meta } = useSmartsheetStoreOrThrow()
const { isNew, state, syncLTARRefs, clearLTARCell, addLTARRef, cleaMMCell } = useProvideSmartsheetRowStore(meta as Ref<TableType>, currentRow)
const { isNew, state, syncLTARRefs, clearLTARCell, addLTARRef, cleaMMCell } = useProvideSmartsheetRowStore(
meta as Ref<TableType>,
currentRow,
)
const reloadViewDataTrigger = inject(ReloadViewDataHookInj)!
@ -41,7 +44,7 @@ defineExpose({
syncLTARRefs,
clearLTARCell,
addLTARRef,
cleaMMCell
cleaMMCell,
})
</script>

27
packages/nc-gui/components/smartsheet/grid/Table.vue

@ -29,15 +29,18 @@ import {
getEnumColorByIndex,
iconMap,
inject,
isBt,
isColumnRequiredAndNull,
isDrawerOrModalExist,
isEeUI,
isMac,
isMm,
message,
onClickOutside,
onMounted,
provide,
ref,
useApi,
useEventListener,
useI18n,
useMultiSelect,
@ -50,7 +53,6 @@ import {
useViewColumnsOrThrow,
useViewsStore,
watch,
useApi
} from '#imports'
import type { CellRange, Row } from '#imports'
@ -291,7 +293,6 @@ async function clearCell(ctx: { row: number; col: number } | null, skipUpdate =
rowId === extractPkFromRow(rowObj.row, meta.value?.columns as ColumnType[]) &&
columnObj.id === col.id
) {
if (rowRefs.value) {
if (isBt(columnObj)) {
rowObj.row[columnObj.title] = row.row[columnObj.title]
@ -299,7 +300,12 @@ async function clearCell(ctx: { row: number; col: number } | null, skipUpdate =
await rowRefs.value[ctx.row]!.addLTARRef(rowObj.row[columnObj.title], columnObj)
await rowRefs.value[ctx.row]!.syncLTARRefs(rowObj.row)
} else if (isMm(columnObj)) {
await api.dbDataTableRow.nestedLink(meta.value?.id as string, columnObj.id as string, encodeURIComponent(rowId as string), mmClearResult)
await api.dbDataTableRow.nestedLink(
meta.value?.id as string,
columnObj.id as string,
encodeURIComponent(rowId as string),
mmClearResult,
)
rowObj.row[columnObj.title] = mmClearResult?.length ? mmClearResult?.length : null
}
}
@ -319,7 +325,7 @@ async function clearCell(ctx: { row: number; col: number } | null, skipUpdate =
args: [clone(ctx), clone(columnObj), clone(rowObj), clone(paginationDataRef.value), mmClearResult],
},
redo: {
fn: async (ctx: { row: number; col: number }, col: ColumnType, row: Row, pg: PaginatedType, mmClearResult:any[]) => {
fn: async (ctx: { row: number; col: number }, col: ColumnType, row: Row, pg: PaginatedType) => {
if (paginationDataRef.value?.pageSize === pg.pageSize) {
if (paginationDataRef.value?.page !== pg.page) {
await changePage?.(pg.page!)
@ -331,7 +337,7 @@ async function clearCell(ctx: { row: number; col: number } | null, skipUpdate =
if (rowRefs.value) {
if (isBt(columnObj)) {
await rowRefs.value[ctx.row]!.clearLTARCell(columnObj)
} else if (isMm(columnObj)){
} else if (isMm(columnObj)) {
await rowRefs.value[ctx.row]!.cleaMMCell(columnObj)
}
}
@ -347,7 +353,7 @@ async function clearCell(ctx: { row: number; col: number } | null, skipUpdate =
throw new Error(t('msg.pageSizeChanged'))
}
},
args: [clone(ctx), clone(columnObj), clone(rowObj), clone(paginationDataRef.value), mmClearResult],
args: [clone(ctx), clone(columnObj), clone(rowObj), clone(paginationDataRef.value)],
},
scope: defineViewScope({ view: view.value }),
})
@ -912,13 +918,20 @@ async function clearSelectedRangeOfCells() {
const cols = fields.value.slice(startCol, endCol + 1)
const rows = dataRef.value.slice(startRow, endRow + 1)
const props = []
let isInfoShown = false
for (const row of rows) {
for (const col of cols) {
if (!row || !col || !col.title) continue
// TODO handle LinkToAnotherRecord
if (isVirtualCol(col)) continue
if (isVirtualCol(col)) {
if ((isBt(col) || isMm(col)) && !isInfoShown) {
message.info(t('msg.info.groupClearIsNotSupportedOnLinksColumn'))
isInfoShown = true
}
continue
}
row.row[col.title] = null
props.push(col.title)

9
packages/nc-gui/composables/useLTARStore.ts

@ -1,14 +1,11 @@
import {
import { UITypes, dateFormats, parseStringDateTime, timeFormats } from 'nocodb-sdk'
import type {
type ColumnType,
type LinkToAnotherRecordType,
type PaginatedType,
RelationTypes,
type RequestParams,
type TableType,
UITypes,
dateFormats,
parseStringDateTime,
timeFormats,
RelationTypes,
} from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue'
import {

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

@ -825,6 +825,7 @@ export function useMultiSelect(
const propsToPaste: string[] = []
let pastedRows = 0
let isInfoShown = false
for (let i = 0; i < pasteMatrixRows; i++) {
const pasteRow = rowsToPaste[i]
@ -838,6 +839,10 @@ export function useMultiSelect(
const pasteCol = colsToPaste[j]
if (!isPasteable(pasteRow, pasteCol)) {
if ((isBt(pasteCol) || isMm(pasteCol)) && !isInfoShown) {
message.info(t('msg.info.groupPasteIsNotSupportedOnLinksColumn'))
isInfoShown = true
}
continue
}
@ -1070,13 +1075,20 @@ export function useMultiSelect(
const props = []
let pasteValue
let isInfoShown = false
const files = e.clipboardData?.files
for (const row of rows) {
// TODO handle insert new row
if (!row || row.rowMeta.new) continue
for (const col of cols) {
if (!col.title || !isPasteable(row, col)) {
if ((isBt(col) || isMm(col)) && !isInfoShown) {
message.info(t('msg.info.groupPasteIsNotSupportedOnLinksColumn'))
isInfoShown = true
}
continue
}

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

@ -190,8 +190,6 @@ const [useProvideSmartsheetRowStore, useSmartsheetRowStore] = useInjectionState(
try {
if (!column || !isLinksOrLTAR(column)) return
const relatedTableMeta = metas.value?.[(<LinkToAnotherRecordType>column?.colOptions)?.fk_related_model_id as string]
if (isNew.value) {
state.value[column.title!] = null
} else if (currentRow.value) {

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

@ -1,7 +1,7 @@
import type { ColumnType, SortType, ViewType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import type { UndoRedoAction } from '~/lib'
import type { EventHook } from '@vueuse/core'
import type { UndoRedoAction } from '~/lib'
import {
IsPublicInj,
ReloadViewDataHookInj,

5
packages/nc-gui/lang/en.json

@ -1255,7 +1255,10 @@
"thankYou": "Thank you!",
"submittedFormData": "You have successfully submitted the form data.",
"editingSystemKeyNotSupported": "Editing system key not supported",
"notAvailableAtTheMoment": "Not available at the moment"
"notAvailableAtTheMoment": "Not available at the moment",
"groupPasteIsNotSupportedOnLinksColumn": "Group paste operation is not supported on Links/LinkToAnotherRecord column",
"groupClearIsNotSupportedOnLinksColumn": "Group clear operation is not supported on Links/LinkToAnotherRecord column"
},
"error": {
"scopesRequired": "Scopes required",

2
packages/nc-gui/utils/dataUtils.ts

@ -1,7 +1,7 @@
import { RelationTypes, UITypes, isLinksOrLTAR, isSystemColumn, isVirtualCol } from 'nocodb-sdk'
import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk'
import type { Row } from '~/lib'
import { isColumnRequiredAndNull } from './columnUtils'
import type { Row } from '~/lib'
export const extractPkFromRow = (row: Record<string, any>, columns: ColumnType[]) => {
if (!row || !columns) return null

1
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -5168,6 +5168,7 @@ class BaseModelSqlv2 {
]),
);
});
if (parentTable.primaryKeys.length > 1) {
childRowsQb.where((qb) => {
for (const childId of childIds) {

Loading…
Cancel
Save