Browse Source

Merge pull request #5063 from nocodb/fix/5052-lookup-attachment

fix: Attachment lookup column bug
pull/5076/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
6587cce3ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/nc-gui/components/cell/attachment/Modal.vue
  2. 31
      packages/nc-gui/components/virtual-cell/Lookup.vue

5
packages/nc-gui/components/cell/attachment/Modal.vue

@ -146,7 +146,10 @@ function onRemoveFileClick(title: any, i: number) {
</div>
</a-tooltip>
<a-tooltip placement="bottom">
<a-tooltip
v-if="isSharedForm || (!readOnly && isUIAllowed('tableAttachment') && !isPublic && !isLocked)"
placement="bottom"
>
<template #title> Rename File </template>
<div class="nc-attachment-download group-hover:(opacity-100) mr-[35px]">

31
packages/nc-gui/components/virtual-cell/Lookup.vue

@ -6,7 +6,6 @@ import {
CellValueInj,
ColumnInj,
MetaInj,
ReadonlyInj,
computed,
inject,
isAttachment,
@ -19,8 +18,6 @@ import {
const { metas, getMeta } = useMetas()
provide(ReadonlyInj, ref(true))
const column = inject(ColumnInj, ref())
const meta = inject(MetaInj, ref())
@ -29,7 +26,7 @@ const cellValue = inject(CellValueInj, ref())
const relationColumn = computed(
() =>
meta.value?.columns?.find((c) => c.id === (column.value?.colOptions as LookupType)?.fk_relation_column_id) as
meta.value?.columns?.find((c: ColumnType) => c.id === (column.value?.colOptions as LookupType)?.fk_relation_column_id) as
| (ColumnType & {
colOptions: LinkToAnotherRecordType | undefined
})
@ -38,7 +35,7 @@ const relationColumn = computed(
watch(
relationColumn,
async (relationCol) => {
async (relationCol: { colOptions: LinkToAnotherRecordType }) => {
if (relationCol && relationCol.colOptions) await getMeta(relationCol.colOptions.fk_related_model_id!)
},
{ immediate: true },
@ -94,30 +91,48 @@ const { showEditNonEditableFieldWarning, showClearNonEditableFieldWarning, activ
:edit-enabled="false"
:model-value="v"
:column="lookupColumn"
:read-only="true"
/>
</template>
<LazySmartsheetVirtualCell v-else :edit-enabled="false" :model-value="arrValue" :column="lookupColumn" />
<LazySmartsheetVirtualCell
v-else
:edit-enabled="false"
:read-only="true"
:model-value="arrValue"
:column="lookupColumn"
/>
</div>
<!-- Render normal cell -->
<template v-else>
<div v-if="isAttachment(lookupColumn) && arrValue[0] && !Array.isArray(arrValue[0]) && typeof arrValue[0] === 'object'">
<LazySmartsheetCell :model-value="arrValue" :column="lookupColumn" :edit-enabled="false" :read-only="true" />
</div>
<!-- For attachment cell avoid adding chip style -->
<template v-else>
<div
v-for="(v, i) of arrValue"
:key="i"
class="min-w-max"
:class="{
'bg-gray-100 px-1 rounded-full flex-1': !isAttachment(lookupColumn),
' border-gray-200 rounded border-1': ![UITypes.Attachment, UITypes.MultiSelect, UITypes.SingleSelect].includes(
'border-gray-200 rounded border-1': ![UITypes.Attachment, UITypes.MultiSelect, UITypes.SingleSelect].includes(
lookupColumn.uidt,
),
}"
>
<LazySmartsheetCell :model-value="v" :column="lookupColumn" :edit-enabled="false" :virtual="true" />
<LazySmartsheetCell
:model-value="v"
:column="lookupColumn"
:edit-enabled="false"
:virtual="true"
:read-only="true"
/>
</div>
</template>
</template>
</template>
</div>
<div>
<div v-if="showEditNonEditableFieldWarning" class="text-left text-wrap mt-2 text-[#e65100] text-xs">

Loading…
Cancel
Save