From 4749171498010d0b34445413c0d1ace3ab5a76c7 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 26 Nov 2022 12:06:08 +0530 Subject: [PATCH] fix: pass array/json array to attachment cell from lookup cell Signed-off-by: Pranav C --- packages/nc-gui/app.vue | 2 +- .../components/smartsheet/header/CellIcon.ts | 1 - .../nc-gui/components/virtual-cell/Lookup.vue | 21 ++++++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/nc-gui/app.vue b/packages/nc-gui/app.vue index ca7bf509fa..b9bcde10f4 100644 --- a/packages/nc-gui/app.vue +++ b/packages/nc-gui/app.vue @@ -36,7 +36,7 @@ if (typeof window !== 'undefined') { diff --git a/packages/nc-gui/components/smartsheet/header/CellIcon.ts b/packages/nc-gui/components/smartsheet/header/CellIcon.ts index 7f29cac1aa..d550bdf77c 100644 --- a/packages/nc-gui/components/smartsheet/header/CellIcon.ts +++ b/packages/nc-gui/components/smartsheet/header/CellIcon.ts @@ -19,7 +19,6 @@ import { isJSON, isPercent, isPhoneNumber, - isPrimary, isRating, isSet, isSingleSelect, diff --git a/packages/nc-gui/components/virtual-cell/Lookup.vue b/packages/nc-gui/components/virtual-cell/Lookup.vue index 9284a52ad4..4ba3a394b3 100644 --- a/packages/nc-gui/components/virtual-cell/Lookup.vue +++ b/packages/nc-gui/components/virtual-cell/Lookup.vue @@ -27,14 +27,6 @@ const meta = inject(MetaInj, ref()) const cellValue = inject(CellValueInj, ref()) -const arrValue = computed(() => { - if (!cellValue.value) return [] - - if (Array.isArray(cellValue.value)) return cellValue.value - - return [cellValue.value] -}) - const relationColumn = computed( () => meta.value?.columns?.find((c) => c.id === (column.value?.colOptions as LookupType)?.fk_relation_column_id) as @@ -66,6 +58,19 @@ const lookupColumn = computed( | undefined, ) +const arrValue = computed(() => { + if (!cellValue.value) return [] + + // if lookup column is Attachment and relation type is Belongs to wrap the value in an array + // since the attachment component expects an array or JSON string array + if (lookupColumn.value?.uidt === UITypes.Attachment && relationColumn.value?.colOptions?.type === RelationTypes.BELONGS_TO) + return [cellValue.value] + + if (Array.isArray(cellValue.value)) return cellValue.value + + return [cellValue.value] +}) + provide(MetaInj, lookupTableMeta) provide(CellUrlDisableOverlayInj, ref(true))