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, removeRowIfNew,
} = useViewData(meta, view, xWhere) } = useViewData(meta, view, xWhere)
const { loadGridViewColumns, updateWidth, resizingColWidth, resizingCol } = useGridViewColumnWidth(view as any) const { loadGridViewColumns, updateWidth, resizingColWidth, resizingCol } = useGridViewColumnWidth(view)
onMounted(loadGridViewColumns) onMounted(loadGridViewColumns)
provide(IsFormInj, ref(false)) provide(IsFormInj, ref(false))

9
packages/nc-gui/composables/useGridViewColumnWidth.ts

@ -1,5 +1,5 @@
import { useStyleTag } from '@vueuse/core' 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 type { Ref } from 'vue'
import { useMetas } from './useMetas' import { useMetas } from './useMetas'
import { useUIPermission } from './useUIPermission' import { useUIPermission } from './useUIPermission'
@ -16,7 +16,7 @@ export function useGridViewColumnWidth(view: Ref<GridType | undefined>) {
const resizingColWidth = ref('200px') const resizingColWidth = ref('200px')
const isPublic = inject(IsPublicInj, ref(false)) 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( watch(
[gridViewCols, resizingCol, resizingColWidth], [gridViewCols, resizingCol, resizingColWidth],
@ -37,9 +37,10 @@ export function useGridViewColumnWidth(view: Ref<GridType | undefined>) {
) )
const loadGridViewColumns = async () => { 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>>( gridViewCols.value = colsData.reduce<Record<string, GridColumnType>>(
(o, col) => ({ (o, col) => ({
...o, ...o,

Loading…
Cancel
Save