Browse Source

fix: shared view injections

pull/6645/head
mertmit 1 year ago
parent
commit
f57dc2bcd2
  1. 2
      packages/nc-gui/components/shared-view/Gallery.vue
  2. 2
      packages/nc-gui/components/shared-view/Grid.vue
  3. 2
      packages/nc-gui/components/shared-view/Kanban.vue
  4. 2
      packages/nc-gui/components/shared-view/Map.vue
  5. 2
      packages/nc-gui/components/smartsheet/column/BarcodeOptions.vue
  6. 2
      packages/nc-gui/components/smartsheet/column/QrCodeOptions.vue
  7. 9
      packages/nc-gui/composables/useViewColumns.ts

2
packages/nc-gui/components/shared-view/Gallery.vue

@ -17,6 +17,8 @@ provide(FieldsInj, ref(meta.value?.columns || []))
provide(IsPublicInj, ref(true))
useProvideViewColumns(sharedView, meta, () => reloadEventHook?.trigger(), true)
useProvideSmartsheetStore(sharedView, meta, true, sorts, nestedFilters)
</script>

2
packages/nc-gui/components/shared-view/Grid.vue

@ -37,6 +37,8 @@ provide(FieldsInj, columns)
provide(IsPublicInj, ref(true))
provide(IsLockedInj, isLocked)
useProvideViewColumns(sharedView, meta, () => reloadEventHook?.trigger(), true)
const { loadGridViewColumns } = useProvideGridViewColumn(sharedView, true)
if (signedIn.value) {

2
packages/nc-gui/components/shared-view/Kanban.vue

@ -25,6 +25,8 @@ provide(FieldsInj, ref(meta.value?.columns || []))
provide(IsPublicInj, ref(true))
useProvideViewColumns(sharedView, meta, () => reloadEventHook?.trigger(), true)
useProvideSmartsheetStore(sharedView, meta, true, sorts, nestedFilters)
useProvideKanbanViewStore(meta, sharedView, true)

2
packages/nc-gui/components/shared-view/Map.vue

@ -25,6 +25,8 @@ provide(FieldsInj, ref(meta.value?.columns || []))
provide(IsPublicInj, ref(true))
useProvideViewColumns(sharedView, meta, () => reloadEventHook?.trigger(), true)
useProvideSmartsheetStore(sharedView, meta, true, sorts, nestedFilters)
useProvideMapViewStore(meta, sharedView, true)

2
packages/nc-gui/components/smartsheet/column/BarcodeOptions.vue

@ -14,8 +14,6 @@ const meta = inject(MetaInj, ref())
const activeView = inject(ActiveViewInj, ref())
const reloadDataHook = inject(ReloadViewDataHookInj)!
const { fields, metaColumnById } = useViewColumnsOrThrow(activeView, meta)
const vModel = useVModel(props, 'modelValue', emit)

2
packages/nc-gui/components/smartsheet/column/QrCodeOptions.vue

@ -16,8 +16,6 @@ const activeView = inject(ActiveViewInj, ref())
const { t } = useI18n()
const reloadDataHook = inject(ReloadViewDataHookInj)!
const { fields, metaColumnById } = useViewColumnsOrThrow(activeView, meta)
const vModel = useVModel(props, 'modelValue', emit)

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

@ -1,7 +1,7 @@
import { ViewTypes, isSystemColumn } from 'nocodb-sdk'
import type { ColumnType, MapType, TableType, ViewType } from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue'
import { IsPublicInj, computed, inject, ref, storeToRefs, useBase, useNuxtApp, useRoles, useUndoRedo, watch } from '#imports'
import { computed, ref, storeToRefs, useBase, useNuxtApp, useRoles, useUndoRedo, watch } from '#imports'
import type { Field } from '#imports'
const [useProvideViewColumns, useViewColumns] = useInjectionState(
@ -9,9 +9,8 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
view: Ref<ViewType | undefined>,
meta: Ref<TableType | undefined> | ComputedRef<TableType | undefined>,
reloadData?: () => void,
isPublic = false,
) => {
const isPublic = inject(IsPublicInj, ref(false))
const fields = ref<Field[]>()
const filterQuery = ref('')
@ -27,7 +26,7 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
const { addUndo, defineViewScope } = useUndoRedo()
const isLocalMode = computed(
() => isPublic.value || !isUIAllowed('viewFieldEdit') || !isUIAllowed('viewFieldEdit') || isSharedBase.value,
() => isPublic || !isUIAllowed('viewFieldEdit') || !isUIAllowed('viewFieldEdit') || isSharedBase.value,
)
const localChanges = ref<Field[]>([])
@ -57,7 +56,7 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
let order = 1
if (view.value?.id) {
const data = (isPublic.value ? meta.value?.columns : (await $api.dbViewColumn.list(view.value.id)).list) as any[]
const data = (isPublic ? meta.value?.columns : (await $api.dbViewColumn.list(view.value.id)).list) as any[]
const fieldById = data.reduce<Record<string, any>>((acc, curr) => {
curr.show = !!curr.show

Loading…
Cancel
Save