Browse Source

fix(nc-gui): fetch view data regardless if meta is present

pull/3606/head
braks 2 years ago
parent
commit
8804bea441
  1. 3
      packages/nc-gui/components/smartsheet/Grid.vue
  2. 9
      packages/nc-gui/composables/useGridViewColumnWidth.ts

3
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))

9
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<GridType | undefined>) {
const resizingColWidth = ref('200px')
const isPublic = inject(IsPublicInj, ref(false))
const columns = computed<ColumnType[]>(() => metas?.value?.[(view.value as any)?.fk_model_id as string]?.columns)
const columns = computed<ColumnType[]>(() => 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<GridType | undefined>) {
)
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<Record<string, GridColumnType>>(
(o, col) => ({
...o,

Loading…
Cancel
Save