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.
31 lines
782 B
31 lines
782 B
2 years ago
|
import { createInjectionState } from '@vueuse/core'
|
||
|
import type { TableType, ViewType } from 'nocodb-sdk'
|
||
|
import type { Ref } from 'vue'
|
||
|
import { useNuxtApp } from '#app'
|
||
|
|
||
|
const [useProvideSmartsheetStore, useSmartsheetStore] = createInjectionState((view: Ref<ViewType>, meta: Ref<TableType>) => {
|
||
|
const { $api } = useNuxtApp()
|
||
|
|
||
|
// state
|
||
|
|
||
|
// getters
|
||
|
const isLocked = computed(() => view?.value?.lock_type === 'locked')
|
||
|
|
||
|
// actions
|
||
|
|
||
|
return {
|
||
|
view,
|
||
|
meta,
|
||
|
isLocked,
|
||
|
$api,
|
||
|
}
|
||
|
})
|
||
|
|
||
|
export { useProvideSmartsheetStore }
|
||
|
|
||
|
export function useSmartsheetStoreOrThrow() {
|
||
|
const smartsheetStore = useSmartsheetStore()
|
||
|
if (smartsheetStore == null) throw new Error('Please call `useSmartsheetStore` on the appropriate parent component')
|
||
|
return smartsheetStore
|
||
|
}
|