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.
86 lines
2.2 KiB
86 lines
2.2 KiB
3 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import type { ColumnType, TableType } from 'nocodb-sdk'
|
||
2 years ago
|
import type { Ref } from 'vue'
|
||
2 years ago
|
import SmartsheetGrid from '../smartsheet/Grid.vue'
|
||
2 years ago
|
import {
|
||
|
ActiveViewInj,
|
||
|
FieldsInj,
|
||
2 years ago
|
IsFormInj,
|
||
2 years ago
|
IsLockedInj,
|
||
|
MetaInj,
|
||
2 years ago
|
OpenNewRecordFormHookInj,
|
||
2 years ago
|
ReloadViewDataHookInj,
|
||
|
computed,
|
||
|
inject,
|
||
|
provide,
|
||
2 years ago
|
provideSidebar,
|
||
2 years ago
|
useMetas,
|
||
|
useProvideSmartsheetStore,
|
||
|
watch,
|
||
|
} from '#imports'
|
||
2 years ago
|
|
||
2 years ago
|
import type { TabItem } from '~/composables'
|
||
3 years ago
|
|
||
2 years ago
|
const { metas } = useMetas()
|
||
3 years ago
|
|
||
2 years ago
|
const activeView = ref()
|
||
|
|
||
|
const el = ref<typeof SmartsheetGrid>()
|
||
|
|
||
2 years ago
|
const fields = ref<ColumnType[]>([])
|
||
|
|
||
2 years ago
|
const tabMeta = inject(
|
||
|
TabMetaInj,
|
||
|
computed(() => ({} as TabItem)),
|
||
|
)
|
||
2 years ago
|
const meta = computed<TableType>(() => metas.value?.[tabMeta?.value?.id as string])
|
||
3 years ago
|
|
||
2 years ago
|
const reloadEventHook = createEventHook<void>()
|
||
2 years ago
|
const openNewRecordFormHook = createEventHook<void>()
|
||
2 years ago
|
|
||
2 years ago
|
const { isGallery, isGrid, isForm, isLocked } = useProvideSmartsheetStore(activeView as Ref<TableType>, meta)
|
||
|
|
||
2 years ago
|
// provide the sidebar injection state
|
||
|
provideSidebar({ storageKey: 'nc-right-sidebar' })
|
||
|
|
||
2 years ago
|
// todo: move to store
|
||
3 years ago
|
provide(MetaInj, meta)
|
||
3 years ago
|
provide(ActiveViewInj, activeView)
|
||
2 years ago
|
provide(IsLockedInj, isLocked)
|
||
2 years ago
|
provide(ReloadViewDataHookInj, reloadEventHook)
|
||
2 years ago
|
provide(OpenNewRecordFormHookInj, openNewRecordFormHook)
|
||
2 years ago
|
provide(FieldsInj, fields)
|
||
2 years ago
|
provide(IsFormInj, isForm)
|
||
3 years ago
|
|
||
2 years ago
|
const treeViewIsLockedInj = inject('TreeViewIsLockedInj', ref(false))
|
||
|
|
||
|
watch(isLocked, (nextValue) => (treeViewIsLockedInj.value = nextValue), { immediate: true })
|
||
3 years ago
|
</script>
|
||
|
|
||
3 years ago
|
<template>
|
||
2 years ago
|
<div class="nc-container flex h-full">
|
||
|
<div class="flex flex-col h-full flex-1 min-w-0">
|
||
|
<SmartsheetToolbar />
|
||
2 years ago
|
|
||
2 years ago
|
<template v-if="meta">
|
||
|
<div class="flex flex-1 min-h-0">
|
||
2 years ago
|
<div v-if="activeView" class="h-full flex-1 min-w-0 min-h-0 bg-gray-50">
|
||
2 years ago
|
<SmartsheetGrid v-if="isGrid" :ref="el" />
|
||
2 years ago
|
|
||
2 years ago
|
<SmartsheetGallery v-else-if="isGallery" />
|
||
2 years ago
|
|
||
2 years ago
|
<SmartsheetForm v-else-if="isForm" />
|
||
2 years ago
|
</div>
|
||
3 years ago
|
</div>
|
||
2 years ago
|
</template>
|
||
|
</div>
|
||
2 years ago
|
<SmartsheetSidebar v-if="meta" class="nc-right-sidebar" />
|
||
3 years ago
|
</div>
|
||
|
</template>
|
||
2 years ago
|
|
||
|
<style scoped>
|
||
|
:deep(.nc-right-sidebar.ant-layout-sider-collapsed) {
|
||
|
@apply !w-0 !max-w-0 !min-w-0 overflow-x-hidden;
|
||
|
}
|
||
|
</style>
|