mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
761 B
23 lines
761 B
2 years ago
|
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 }
|
||
|
}
|