mirror of https://github.com/nocodb/nocodb
91 lines
2.4 KiB
91 lines
2.4 KiB
<script setup lang="ts"> |
|
import type { ColumnType, TableType } from 'nocodb-sdk' |
|
import { |
|
ActiveViewInj, |
|
FieldsInj, |
|
IsFormInj, |
|
IsLockedInj, |
|
MetaInj, |
|
OpenNewRecordFormHookInj, |
|
ReloadViewDataHookInj, |
|
ReloadViewMetaHookInj, |
|
TabMetaInj, |
|
computed, |
|
createEventHook, |
|
inject, |
|
provide, |
|
ref, |
|
useMetas, |
|
useProvideSmartsheetStore, |
|
watch, |
|
} from '#imports' |
|
import type { TabItem } from '~/composables' |
|
|
|
const { activeTab } = defineProps<{ |
|
activeTab: TabItem |
|
}>() |
|
|
|
const { metas } = useMetas() |
|
|
|
const activeView = ref() |
|
|
|
const el = ref() |
|
|
|
const fields = ref<ColumnType[]>([]) |
|
|
|
provide(TabMetaInj, ref(activeTab)) |
|
const meta = computed<TableType>(() => metas.value?.[activeTab?.id as string]) |
|
|
|
const reloadEventHook = createEventHook() |
|
const reloadViewMetaEventHook = createEventHook() |
|
const openNewRecordFormHook = createEventHook() |
|
|
|
const { isGallery, isGrid, isForm, isLocked } = useProvideSmartsheetStore(activeView, meta) |
|
|
|
// provide the sidebar injection state |
|
useSidebar('nc-right-sidebar', { useStorage: true, isOpen: true }) |
|
|
|
// todo: move to store |
|
provide(MetaInj, meta) |
|
provide(ActiveViewInj, activeView) |
|
provide(IsLockedInj, isLocked) |
|
provide(ReloadViewDataHookInj, reloadEventHook) |
|
provide(ReloadViewMetaHookInj, reloadViewMetaEventHook) |
|
provide(OpenNewRecordFormHookInj, openNewRecordFormHook) |
|
provide(FieldsInj, fields) |
|
provide(IsFormInj, isForm) |
|
|
|
const treeViewIsLockedInj = inject('TreeViewIsLockedInj', ref(false)) |
|
|
|
watch(isLocked, (nextValue) => (treeViewIsLockedInj.value = nextValue), { immediate: true }) |
|
</script> |
|
|
|
<template> |
|
<div class="nc-container flex h-full"> |
|
<div class="flex flex-col h-full flex-1 min-w-0"> |
|
<LazySmartsheetToolbar /> |
|
|
|
<Transition name="layout" mode="out-in"> |
|
<template v-if="meta"> |
|
<div class="flex flex-1 min-h-0"> |
|
<div v-if="activeView" class="h-full flex-1 min-w-0 min-h-0 bg-gray-50"> |
|
<LazySmartsheetGrid v-if="isGrid" :ref="el" /> |
|
|
|
<LazySmartsheetGallery v-else-if="isGallery" /> |
|
|
|
<LazySmartsheetForm v-else-if="isForm && !$route.query.reload" /> |
|
</div> |
|
</div> |
|
</template> |
|
</Transition> |
|
</div> |
|
|
|
<LazySmartsheetSidebar v-if="meta" class="nc-right-sidebar" /> |
|
</div> |
|
</template> |
|
|
|
<style scoped> |
|
:deep(.nc-right-sidebar.ant-layout-sider-collapsed) { |
|
@apply !w-0 !max-w-0 !min-w-0 overflow-x-hidden; |
|
} |
|
</style>
|
|
|