Browse Source

mobile optimisations - work on merging right and left sidebar (WIP)

pull/4898/head
Daniel Spaude 2 years ago
parent
commit
270be1bdd6
No known key found for this signature in database
GPG Key ID: 654A3D1FA4F35FFE
  1. 4
      packages/nc-gui/components/smartsheet/sidebar/index.vue
  2. 4
      packages/nc-gui/components/smartsheet/sidebar/mobile.vue
  3. 16
      packages/nc-gui/composables/useViews.ts
  4. 2
      packages/nc-gui/pages/[projectType]/[projectId]/index.vue

4
packages/nc-gui/components/smartsheet/sidebar/index.vue

@ -13,7 +13,7 @@ import {
useRouter,
useSidebar,
useUIPermission,
useViews,
useViewsStoreOrThrow,
watch,
} from '#imports'
@ -23,7 +23,7 @@ const activeView = inject(ActiveViewInj, ref())
const { activeTab } = useTabs()
const { views, loadViews, isLoading } = useViews(meta)
const { views, loadViews, isLoading } = useViewsStoreOrThrow()
const { lastOpenedViewMap } = useProject()

4
packages/nc-gui/components/smartsheet/sidebar/mobile.vue

@ -13,7 +13,7 @@ import {
useRouter,
useSidebar,
useUIPermission,
useViews,
useViewsStoreOrThrow,
watch,
} from '#imports'
@ -25,7 +25,7 @@ const activeView = inject(ActiveViewInj, ref())
const { activeTab } = useTabs()
const { views, loadViews, isLoading } = useViews(meta)
const { views, loadViews, isLoading } = useViewsStoreOrThrow()
const { lastOpenedViewMap } = useProject()

16
packages/nc-gui/composables/useViews.ts

@ -2,13 +2,17 @@ import type { TableType, ViewType } from 'nocodb-sdk'
import type { MaybeRef } from '@vueuse/core'
import { ref, unref, useNuxtApp, watch } from '#imports'
export function useViews(meta: MaybeRef<TableType | undefined>) {
const [useProvideViewsStore, useViewsStore] = useInjectionState((meta: MaybeRef<TableType | undefined>) => {
// debugger
// console.log('--------------------useViews--------------------')
// console.trace()
const views = ref<ViewType[]>([])
const isLoading = ref(false)
const { $api } = useNuxtApp()
const loadViews = async () => {
// debugger
isLoading.value = true
const _meta = unref(meta)
@ -25,4 +29,14 @@ export function useViews(meta: MaybeRef<TableType | undefined>) {
watch(() => unref(meta), loadViews, { immediate: true })
return { views, isLoading, loadViews }
}, 'views-store')
export { useProvideViewsStore }
export function useViewsStoreOrThrow() {
const viewsStore = useViewsStore()
if (viewsStore == null) throw new Error('Please call `useProvideViewsStore` on the appropriate parent component')
return viewsStore
}

2
packages/nc-gui/pages/[projectType]/[projectId]/index.vue

@ -77,6 +77,8 @@ const meta = computed<TableType | undefined>(() => activeTab.value && metas.valu
provide(ActiveViewInj, activeView)
provide(MetaInj, meta)
useProvideViewsStore(meta)
const showViewsMobileSidebar = ref(false)
/** Sidebar ref */

Loading…
Cancel
Save