Browse Source

fix: review changes nocodb/nocodb/pull/7491

pull/7491/head
Ramesh Mane 10 months ago
parent
commit
2f79e7089e
  1. 2
      packages/nc-gui/components/account/UserMenu.vue
  2. 2
      packages/nc-gui/components/project/AccessSettings.vue
  3. 6
      packages/nc-gui/components/smartsheet/grid/Table.vue
  4. 8
      packages/nc-gui/composables/useMultiSelect/convertCellData.ts
  5. 57
      packages/nc-gui/composables/useMultiSelect/index.ts
  6. 16
      packages/nocodb-sdk/src/lib/helperFunctions.ts

2
packages/nc-gui/components/account/UserMenu.vue

@ -4,7 +4,7 @@ import type { UsersSortType } from '~/lib'
const { field, direction, handleUserSort } = defineProps<{ const { field, direction, handleUserSort } = defineProps<{
field: UsersSortType['field'] field: UsersSortType['field']
direction?: UsersSortType['direction'] direction: UsersSortType['direction']
handleUserSort: Function handleUserSort: Function
}>() }>()

2
packages/nc-gui/components/project/AccessSettings.vue

@ -156,7 +156,7 @@ onMounted(async () => {
v-else-if="!filteredCollaborators?.length" v-else-if="!filteredCollaborators?.length"
class="nc-collaborators-list w-full h-full flex flex-col items-center justify-center mt-36" class="nc-collaborators-list w-full h-full flex flex-col items-center justify-center mt-36"
> >
<a-empty description="$t('title.noMembersFound')" /> <Empty description="$t('title.noMembersFound')" />
</div> </div>
<div v-else class="nc-collaborators-list mt-6 h-full"> <div v-else class="nc-collaborators-list mt-6 h-full">
<div class="flex flex-col rounded-lg overflow-hidden border-1 max-w-350 max-h-[calc(100%-8rem)]"> <div class="flex flex-col rounded-lg overflow-hidden border-1 max-w-350 max-h-[calc(100%-8rem)]">

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

@ -1732,7 +1732,7 @@ onKeyStroke('ArrowDown', onDown)
v-if="contextMenuTarget && hasEditPermission" v-if="contextMenuTarget && hasEditPermission"
class="nc-base-menu-item" class="nc-base-menu-item"
data-testid="context-menu-item-paste" data-testid="context-menu-item-paste"
:disabled="!!isSystemColumn(fields[contextMenuTarget.col])" :disabled="isSystemColumn(fields[contextMenuTarget.col])"
@click="paste" @click="paste"
> >
<div v-e="['a:row:paste']" class="flex gap-2 items-center"> <div v-e="['a:row:paste']" class="flex gap-2 items-center">
@ -1751,7 +1751,7 @@ onKeyStroke('ArrowDown', onDown)
(isLinksOrLTAR(fields[contextMenuTarget.col]) || !isVirtualCol(fields[contextMenuTarget.col])) (isLinksOrLTAR(fields[contextMenuTarget.col]) || !isVirtualCol(fields[contextMenuTarget.col]))
" "
class="nc-base-menu-item" class="nc-base-menu-item"
:disabled="!!isSystemColumn(fields[contextMenuTarget.col])" :disabled="isSystemColumn(fields[contextMenuTarget.col])"
data-testid="context-menu-item-clear" data-testid="context-menu-item-clear"
@click="clearCell(contextMenuTarget)" @click="clearCell(contextMenuTarget)"
> >
@ -1765,7 +1765,7 @@ onKeyStroke('ArrowDown', onDown)
<NcMenuItem <NcMenuItem
v-else-if="contextMenuTarget && hasEditPermission" v-else-if="contextMenuTarget && hasEditPermission"
class="nc-base-menu-item" class="nc-base-menu-item"
:disabled="!!isSystemColumn(fields[contextMenuTarget.col])" :disabled="isSystemColumn(fields[contextMenuTarget.col])"
data-testid="context-menu-item-clear" data-testid="context-menu-item-clear"
@click="clearSelectedRangeOfCells()" @click="clearSelectedRangeOfCells()"
> >

8
packages/nc-gui/composables/useMultiSelect/convertCellData.ts

@ -182,7 +182,13 @@ export default function convertCellData(
attachments.push(attachment) attachments.push(attachment)
} }
return attachments.length ? (value ? JSON.stringify(attachments) : files ? attachments : null) : null if (value && attachments.length) {
return JSON.stringify(attachments)
} else if (files && attachments.length) {
return attachments
} else {
return null
}
} }
case UITypes.SingleSelect: case UITypes.SingleSelect:
case UITypes.MultiSelect: { case UITypes.MultiSelect: {

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

@ -912,24 +912,27 @@ export function useMultiSelect(
const rows = unref(data).slice(startRow, endRow + 1) const rows = unref(data).slice(startRow, endRow + 1)
const props = [] const props = []
if (e.clipboardData?.files?.length) { let pasteValue
let pasteValue const files = e.clipboardData?.files
for (const row of rows) { for (const row of rows) {
// TODO handle insert new row // TODO handle insert new row
if (!row || row.rowMeta.new) continue if (!row || row.rowMeta.new) continue
for (const col of cols) { for (const col of cols) {
if (!col.title || !isPasteable(row, col) || col.uidt !== UITypes.Attachment) { if (!col.title || !isPasteable(row, col)) {
continue
}
if (files?.length) {
if (col.uidt !== UITypes.Attachment) {
continue continue
} }
props.push(col.title)
if (pasteValue === undefined) { if (pasteValue === undefined) {
const fileUploadPayload = convertCellData( const fileUploadPayload = convertCellData(
{ {
value: '', value: '',
files: e.clipboardData?.files, files: files,
to: col.uidt as UITypes, to: col.uidt as UITypes,
column: col, column: col,
appInfo: unref(appInfo), appInfo: unref(appInfo),
@ -943,27 +946,8 @@ export function useMultiSelect(
pasteValue = Array.isArray(uploadedFiles) && uploadedFiles.length ? JSON.stringify(uploadedFiles) : null pasteValue = Array.isArray(uploadedFiles) && uploadedFiles.length ? JSON.stringify(uploadedFiles) : null
} }
} }
} else {
if (pasteValue !== undefined) { pasteValue = convertCellData(
row.row[col.title] = pasteValue
}
}
}
} else {
for (const row of rows) {
// TODO handle insert new row
if (!row || row.rowMeta.new) continue
for (const col of cols) {
if (!col.title) continue
if (!isPasteable(row, col)) {
continue
}
props.push(col.title)
const pasteValue = convertCellData(
{ {
value: clipboardData, value: clipboardData,
to: col.uidt as UITypes, to: col.uidt as UITypes,
@ -973,13 +957,16 @@ export function useMultiSelect(
isMysql(meta.value?.source_id), isMysql(meta.value?.source_id),
true, true,
) )
}
if (pasteValue !== undefined) { props.push(col.title)
row.row[col.title] = pasteValue
} if (pasteValue !== undefined) {
row.row[col.title] = pasteValue
} }
} }
} }
if (!props.length) return if (!props.length) return
await bulkUpdateRows?.(rows, props) await bulkUpdateRows?.(rows, props)
} }

16
packages/nocodb-sdk/src/lib/helperFunctions.ts

@ -14,13 +14,15 @@ const getSystemColumnsIds = (columns) => {
const getSystemColumns = (columns) => columns.filter(isSystemColumn) || []; const getSystemColumns = (columns) => columns.filter(isSystemColumn) || [];
const isSystemColumn = (col): boolean => const isSystemColumn = (col): boolean =>
col && !!(
(col.uidt === UITypes.ForeignKey || col &&
((col.column_name === 'created_at' || col.column_name === 'updated_at') && (col.uidt === UITypes.ForeignKey ||
col.uidt === UITypes.DateTime) || ((col.column_name === 'created_at' || col.column_name === 'updated_at') &&
(col.pk && (col.ai || col.cdf)) || col.uidt === UITypes.DateTime) ||
(col.pk && col.meta && col.meta.ag) || (col.pk && (col.ai || col.cdf)) ||
col.system); (col.pk && col.meta && col.meta.ag) ||
col.system)
);
const isSelfReferencingTableColumn = (col): boolean => { const isSelfReferencingTableColumn = (col): boolean => {
return ( return (

Loading…
Cancel
Save