Browse Source

fix: review changes nocodb/nocodb/pull/7491

pull/7491/head
Ramesh Mane 11 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<{
field: UsersSortType['field']
direction?: UsersSortType['direction']
direction: UsersSortType['direction']
handleUserSort: Function
}>()

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

@ -156,7 +156,7 @@ onMounted(async () => {
v-else-if="!filteredCollaborators?.length"
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 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)]">

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

@ -1732,7 +1732,7 @@ onKeyStroke('ArrowDown', onDown)
v-if="contextMenuTarget && hasEditPermission"
class="nc-base-menu-item"
data-testid="context-menu-item-paste"
:disabled="!!isSystemColumn(fields[contextMenuTarget.col])"
:disabled="isSystemColumn(fields[contextMenuTarget.col])"
@click="paste"
>
<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]))
"
class="nc-base-menu-item"
:disabled="!!isSystemColumn(fields[contextMenuTarget.col])"
:disabled="isSystemColumn(fields[contextMenuTarget.col])"
data-testid="context-menu-item-clear"
@click="clearCell(contextMenuTarget)"
>
@ -1765,7 +1765,7 @@ onKeyStroke('ArrowDown', onDown)
<NcMenuItem
v-else-if="contextMenuTarget && hasEditPermission"
class="nc-base-menu-item"
:disabled="!!isSystemColumn(fields[contextMenuTarget.col])"
:disabled="isSystemColumn(fields[contextMenuTarget.col])"
data-testid="context-menu-item-clear"
@click="clearSelectedRangeOfCells()"
>

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

@ -182,7 +182,13 @@ export default function convertCellData(
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.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 props = []
if (e.clipboardData?.files?.length) {
let pasteValue
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) || col.uidt !== UITypes.Attachment) {
let pasteValue
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)) {
continue
}
if (files?.length) {
if (col.uidt !== UITypes.Attachment) {
continue
}
props.push(col.title)
if (pasteValue === undefined) {
const fileUploadPayload = convertCellData(
{
value: '',
files: e.clipboardData?.files,
files: files,
to: col.uidt as UITypes,
column: col,
appInfo: unref(appInfo),
@ -943,27 +946,8 @@ export function useMultiSelect(
pasteValue = Array.isArray(uploadedFiles) && uploadedFiles.length ? JSON.stringify(uploadedFiles) : null
}
}
if (pasteValue !== undefined) {
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(
} else {
pasteValue = convertCellData(
{
value: clipboardData,
to: col.uidt as UITypes,
@ -973,13 +957,16 @@ export function useMultiSelect(
isMysql(meta.value?.source_id),
true,
)
}
if (pasteValue !== undefined) {
row.row[col.title] = pasteValue
}
props.push(col.title)
if (pasteValue !== undefined) {
row.row[col.title] = pasteValue
}
}
}
if (!props.length) return
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 isSystemColumn = (col): boolean =>
col &&
(col.uidt === UITypes.ForeignKey ||
((col.column_name === 'created_at' || col.column_name === 'updated_at') &&
col.uidt === UITypes.DateTime) ||
(col.pk && (col.ai || col.cdf)) ||
(col.pk && col.meta && col.meta.ag) ||
col.system);
!!(
col &&
(col.uidt === UITypes.ForeignKey ||
((col.column_name === 'created_at' || col.column_name === 'updated_at') &&
col.uidt === UITypes.DateTime) ||
(col.pk && (col.ai || col.cdf)) ||
(col.pk && col.meta && col.meta.ag) ||
col.system)
);
const isSelfReferencingTableColumn = (col): boolean => {
return (

Loading…
Cancel
Save