mirror of https://github.com/nocodb/nocodb
Muhammed Mustafa
2 years ago
8 changed files with 96 additions and 11 deletions
@ -0,0 +1,22 @@
|
||||
import type { ColumnType, TableType, ViewType } from 'nocodb-sdk' |
||||
import { useNuxtApp } from '#app' |
||||
|
||||
export function useSharedView(viewId: string) { |
||||
const sharedView = ref<ViewType>() |
||||
const meta = computed<TableType>(() => sharedView.value.model) |
||||
const columns = computed<ColumnType[]>(() => sharedView.value?.model?.columns ?? []) |
||||
|
||||
const { $api } = useNuxtApp() |
||||
const { setMeta } = useMetas() |
||||
|
||||
const loadSharedView = async () => { |
||||
const viewMeta = await $api.public.sharedViewMetaGet(viewId) |
||||
sharedView.value = viewMeta |
||||
setMeta(viewMeta.model) |
||||
|
||||
const relatedMetas = { ...viewMeta.relatedMetas } |
||||
Object.keys(relatedMetas).forEach((key) => setMeta(relatedMetas[key])) |
||||
} |
||||
|
||||
return { sharedView, loadSharedView, meta, columns } |
||||
} |
@ -0,0 +1,30 @@
|
||||
<script setup lang="ts"> |
||||
import type { Ref } from 'vue' |
||||
import type { TableType } from 'nocodb-sdk/build/main' |
||||
import { ActiveViewInj, FieldsInj, IsPublicInj, MetaInj, ReloadViewDataHookInj } from '~/context' |
||||
|
||||
definePageMeta({ |
||||
requiresAuth: false, |
||||
}) |
||||
|
||||
const route = useRoute() |
||||
|
||||
const reloadEventHook = createEventHook<void>() |
||||
const { sharedView, loadSharedView, meta, columns } = useSharedView(route.params.viewId as string) |
||||
|
||||
await loadSharedView() |
||||
|
||||
provide(ReloadViewDataHookInj, reloadEventHook) |
||||
provide(MetaInj, meta) |
||||
provide(ActiveViewInj, sharedView) |
||||
provide(FieldsInj, ref(columns)) |
||||
provide(IsPublicInj, ref(true)) |
||||
|
||||
const { isGrid } = useProvideSmartsheetStore(sharedView as Ref<TableType>, meta) |
||||
</script> |
||||
|
||||
<template> |
||||
<NuxtLayout id="content" class="flex"> |
||||
<SmartsheetGrid :is-public-view="true" /> |
||||
</NuxtLayout> |
||||
</template> |
Loading…
Reference in new issue