From fca55cffb209609fb787f9b96133d8764f4d4c85 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 29 Sep 2022 16:12:58 +0200 Subject: [PATCH] chore(nc-gui): remove useVirtualCell --- .../composables/useSmartsheetRowStore.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/nc-gui/composables/useSmartsheetRowStore.ts b/packages/nc-gui/composables/useSmartsheetRowStore.ts index 7c710d9d1c..47a00d4661 100644 --- a/packages/nc-gui/composables/useSmartsheetRowStore.ts +++ b/packages/nc-gui/composables/useSmartsheetRowStore.ts @@ -8,6 +8,9 @@ import { deepCompare, extractPkFromRow, extractSdkResponseErrorMsg, + isBt, + isHm, + isMm, message, ref, unref, @@ -16,7 +19,6 @@ import { useMetas, useNuxtApp, useProject, - useVirtualCell, } from '#imports' import type { Row } from '~/lib' @@ -36,12 +38,11 @@ const [useProvideSmartsheetRowStore, useSmartsheetRowStore] = useInjectionState( const state = ref | Record[] | null>>({}) // getters - const isNew = computed(() => unref(row).rowMeta?.new ?? false) + const isNew = computed(() => unref(row).rowMeta.new ?? false) // actions const addLTARRef = async (value: Record, column: ColumnType) => { - const { isHm, isMm, isBt } = $(useVirtualCell(ref(column))) - if (isHm || isMm) { + if (isHm(column) || isMm(column)) { if (!state.value[column.title!]) state.value[column.title!] = [] if (state.value[column.title!]!.find((ln: Record) => deepCompare(ln, value))) { @@ -50,17 +51,16 @@ const [useProvideSmartsheetRowStore, useSmartsheetRowStore] = useInjectionState( } state.value[column.title!]!.push(value) - } else if (isBt) { + } else if (isBt(column)) { state.value[column.title!] = value } } // actions const removeLTARRef = async (value: Record, column: ColumnType) => { - const { isHm, isMm, isBt } = $(useVirtualCell(ref(column))) - if (isHm || isMm) { + if (isHm(column) || isMm(column)) { state.value[column.title!]?.splice(state.value[column.title!]?.indexOf(value), 1) - } else if (isBt) { + } else if (isBt(column)) { state.value[column.title!] = null } } @@ -92,13 +92,14 @@ const [useProvideSmartsheetRowStore, useSmartsheetRowStore] = useInjectionState( const id = extractPkFromRow(row, metaValue?.columns as ColumnType[]) for (const column of metaValue?.columns ?? []) { if (column.uidt !== UITypes.LinkToAnotherRecord) continue - const colOptions = column?.colOptions as LinkToAnotherRecordType - const { isHm, isMm, isBt } = $(useVirtualCell(ref(column))) + const colOptions = column.colOptions as LinkToAnotherRecordType + const relatedTableMeta = metas.value?.[colOptions?.fk_related_model_id as string] - if (isHm || isMm) { + if (isHm(column) || isMm(column)) { const relatedRows = (state.value?.[column.title!] ?? []) as Record[] + for (const relatedRow of relatedRows) { await linkRecord( id, @@ -108,7 +109,7 @@ const [useProvideSmartsheetRowStore, useSmartsheetRowStore] = useInjectionState( { metaValue }, ) } - } else if (isBt && state?.value?.[column.title!]) { + } else if (isBt(column) && state.value?.[column.title!]) { await linkRecord( id, extractPkFromRow(state.value?.[column.title!] as Record, relatedTableMeta.columns as ColumnType[]),