From 8804bea441d556124f23be2d2bc1868df63acb27 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Wed, 14 Sep 2022 12:49:04 +0200 Subject: [PATCH] fix(nc-gui): fetch view data regardless if meta is present --- packages/nc-gui/components/smartsheet/Grid.vue | 3 ++- packages/nc-gui/composables/useGridViewColumnWidth.ts | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index 7d80468beb..efb4a3e99a 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -94,7 +94,8 @@ const { removeRowIfNew, } = useViewData(meta, view, xWhere) -const { loadGridViewColumns, updateWidth, resizingColWidth, resizingCol } = useGridViewColumnWidth(view as any) +const { loadGridViewColumns, updateWidth, resizingColWidth, resizingCol } = useGridViewColumnWidth(view) + onMounted(loadGridViewColumns) provide(IsFormInj, ref(false)) diff --git a/packages/nc-gui/composables/useGridViewColumnWidth.ts b/packages/nc-gui/composables/useGridViewColumnWidth.ts index 886b2436b8..a85e7b036f 100644 --- a/packages/nc-gui/composables/useGridViewColumnWidth.ts +++ b/packages/nc-gui/composables/useGridViewColumnWidth.ts @@ -1,5 +1,5 @@ import { useStyleTag } from '@vueuse/core' -import type { ColumnType, GridColumnType, GridType } from 'nocodb-sdk' +import type { ColumnType, GridColumnType, GridType, ViewType } from 'nocodb-sdk' import type { Ref } from 'vue' import { useMetas } from './useMetas' import { useUIPermission } from './useUIPermission' @@ -16,7 +16,7 @@ export function useGridViewColumnWidth(view: Ref) { const resizingColWidth = ref('200px') const isPublic = inject(IsPublicInj, ref(false)) - const columns = computed(() => metas?.value?.[(view.value as any)?.fk_model_id as string]?.columns) + const columns = computed(() => metas.value?.[(view.value as ViewType)?.fk_model_id as string]?.columns || []) watch( [gridViewCols, resizingCol, resizingColWidth], @@ -37,9 +37,10 @@ export function useGridViewColumnWidth(view: Ref) { ) const loadGridViewColumns = async () => { - if ((!view.value || view.value?.id) && !isPublic.value) return + if (!view.value?.id && !isPublic.value) return - const colsData: GridColumnType[] = (isPublic.value ? columns.value : await $api.dbView.gridColumnsList(view.value!.id!)) ?? [] + const colsData: GridColumnType[] = (isPublic.value ? columns.value : await $api.dbView.gridColumnsList(view.value!.id!) +) ?? [] gridViewCols.value = colsData.reduce>( (o, col) => ({ ...o,