Browse Source

fix: Remvoed useSmartsheetStore dependecy with ViewACtionsMenu and sidebar and added proxy states to views store

pull/6888/head
Muhammed Mustafa 1 year ago
parent
commit
c093559183
  1. 6
      packages/nc-gui/components/smartsheet/toolbar/ExportSubActions.vue
  2. 22
      packages/nc-gui/composables/useSmartsheetStore.ts
  3. 4
      packages/nc-gui/lang/en.json
  4. 10
      packages/nc-gui/store/views.ts

6
packages/nc-gui/components/smartsheet/toolbar/ExportSubActions.vue

@ -13,13 +13,9 @@ import {
ref, ref,
storeToRefs, storeToRefs,
useBase, useBase,
useI18n,
useNuxtApp, useNuxtApp,
useSmartsheetStoreOrThrow,
} from '#imports' } from '#imports'
const { t } = useI18n()
const isPublicView = inject(IsPublicInj, ref(false)) const isPublicView = inject(IsPublicInj, ref(false))
const fields = inject(FieldsInj, ref([])) const fields = inject(FieldsInj, ref([]))
@ -33,7 +29,7 @@ const meta = inject(MetaInj, ref())
const selectedView = inject(ActiveViewInj) const selectedView = inject(ActiveViewInj)
const { sorts, nestedFilters } = useSmartsheetStoreOrThrow() const { activeNestedFilters: nestedFilters, activeSorts: sorts } = storeToRefs(useViewsStore())
const isExportingType = ref<ExportTypes | undefined>(undefined) const isExportingType = ref<ExportTypes | undefined>(undefined)

22
packages/nc-gui/composables/useSmartsheetStore.ts

@ -15,7 +15,7 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState(
) => { ) => {
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const { activeView: view } = storeToRefs(useViewsStore()) const { activeView: view, activeNestedFilters, activeSorts } = storeToRefs(useViewsStore())
const baseStore = useBase() const baseStore = useBase()
@ -57,6 +57,26 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState(
const sorts = ref<SortType[]>(unref(initialSorts) ?? []) const sorts = ref<SortType[]>(unref(initialSorts) ?? [])
const nestedFilters = ref<FilterType[]>(unref(initialFilters) ?? []) const nestedFilters = ref<FilterType[]>(unref(initialFilters) ?? [])
watch(
sorts,
() => {
activeSorts.value = sorts.value
},
{
immediate: true,
},
)
watch(
nestedFilters,
() => {
activeNestedFilters.value = nestedFilters.value
},
{
immediate: true,
},
)
return { return {
view, view,
meta, meta,

4
packages/nc-gui/lang/en.json

@ -748,8 +748,8 @@
"deleteSelectedRow": "Delete Selected Records", "deleteSelectedRow": "Delete Selected Records",
"importExcel": "Import Excel", "importExcel": "Import Excel",
"importCSV": "Import CSV", "importCSV": "Import CSV",
"downloadCSV": "Download as CSV", "downloadCSV": "Download CSV",
"downloadExcel": "Download as XLSX", "downloadExcel": "Download Excel",
"uploadCSV": "Upload CSV", "uploadCSV": "Upload CSV",
"import": "Import", "import": "Import",
"importMetadata": "Import Metadata", "importMetadata": "Import Metadata",

10
packages/nc-gui/store/views.ts

@ -1,4 +1,4 @@
import type { ViewType, ViewTypes } from 'nocodb-sdk' import type { FilterType, SortType, ViewType, ViewTypes } from 'nocodb-sdk'
import { acceptHMRUpdate, defineStore } from 'pinia' import { acceptHMRUpdate, defineStore } from 'pinia'
import type { ViewPageType } from '~/lib' import type { ViewPageType } from '~/lib'
@ -41,6 +41,12 @@ export const useViewsStore = defineStore('viewsStore', () => {
}, },
}) })
// Both are synced with `useSmartsheetStore` state
// Sort of active view
const activeSorts = ref<SortType[]>([])
// Filters of active view (used for local filters)
const activeNestedFilters = ref<FilterType[]>([])
const isViewsLoading = ref(true) const isViewsLoading = ref(true)
const isViewDataLoading = ref(true) const isViewDataLoading = ref(true)
const isPublic = computed(() => route.value.meta?.public) const isPublic = computed(() => route.value.meta?.public)
@ -304,6 +310,8 @@ export const useViewsStore = defineStore('viewsStore', () => {
navigateToView, navigateToView,
changeView, changeView,
removeFromRecentViews, removeFromRecentViews,
activeSorts,
activeNestedFilters,
} }
}) })

Loading…
Cancel
Save