Browse Source

wip(gui-v2): keep tab level view state(filter/sort/fields)

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3370/head
Pranav C 2 years ago
parent
commit
e3dc42bf76
  1. 13
      packages/nc-gui/components/tabs/Smartsheet.vue
  2. 2
      packages/nc-gui/composables/useViewFilters.ts

13
packages/nc-gui/components/tabs/Smartsheet.vue

@ -1,5 +1,5 @@
<script setup lang="ts">
import type { ColumnType, TableType } from 'nocodb-sdk'
import type { ColumnType, TableType, ViewType } from 'nocodb-sdk'
import {
ActiveViewInj,
FieldsInj,
@ -37,7 +37,7 @@ const meta = computed<TableType | undefined>(() => activeTab.value && metas.valu
const reloadEventHook = createEventHook()
const { isGallery, isGrid, isForm, isKanban, isLocked } = useProvideSmartsheetStore(activeView, meta)
const { isGallery, isGrid, isForm, isKanban, isLocked, nestedFilters } = useProvideSmartsheetStore(activeView, meta)
const openNewRecordFormHook = createEventHook()
@ -55,6 +55,15 @@ provide(OpenNewRecordFormHookInj, openNewRecordFormHook)
provide(FieldsInj, fields)
provide(IsFormInj, isForm)
provide(TabMetaInj, activeTab)
watch(nestedFilters, (newFilters) => {
activeTab.value.state = activeTab.value.state || {}
activeTab.value.state[activeView.value.id] = newFilters
})
watch(activeView, (newView: ViewType) => {
nestedFilters.value = activeTab.value.state?.[newView.id!]
})
</script>
<template>

2
packages/nc-gui/composables/useViewFilters.ts

@ -37,7 +37,7 @@ export function useViewFilters(
const _filters = ref<Filter[]>([])
const nestedMode = computed(() => isPublic.value || !isUIAllowed('filterSync' || !isUIAllowed('filterChildrenRead')))
const nestedMode = computed(() => isPublic.value || !isUIAllowed('filterSync') || !isUIAllowed('filterChildrenRead'))
const filters = computed<Filter[]>({
get: () => (nestedMode.value ? currentFilters! : _filters.value),

Loading…
Cancel
Save