Browse Source

wip(gui-v2): sorts state

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

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

@ -37,7 +37,7 @@ const meta = computed<TableType | undefined>(() => activeTab.value && metas.valu
const reloadEventHook = createEventHook()
const { isGallery, isGrid, isForm, isKanban, isLocked, nestedFilters } = useProvideSmartsheetStore(activeView, meta)
const { isGallery, isGrid, isForm, isKanban, isLocked, nestedFilters, sorts } = useProvideSmartsheetStore(activeView, meta)
const openNewRecordFormHook = createEventHook()
@ -45,6 +45,27 @@ const reloadViewMetaEventHook = createEventHook()
useProvideKanbanViewStore(meta, activeView)
/** keep view level state in tabMeta and restore on view change */
watch(nestedFilters, (newFilters) => {
activeTab.value.state = activeTab.value.state || {}
activeTab.value.state[activeView.value.id] = activeTab.value.state[activeView.value.id] || {}
activeTab.value.state[activeView.value.id].filters = newFilters
})
watch(sorts, (newSorts) => {
activeTab.value.state = activeTab.value.state || {}
activeTab.value.state[activeView.value.id] = activeTab.value.state[activeView.value.id] || {}
activeTab.value.state[activeView.value.id].sorts = newSorts
})
watch(activeView, (newView: ViewType) => {
if (activeTab.value.state?.[newView.id!]?.filters)
nestedFilters.value = activeTab.value.state?.[newView.id!]?.filters || []
if (activeTab.value.state?.[newView.id!]?.sorts)
sorts.value = activeTab.value.state?.[newView.id!]?.sorts || []
})
// todo: move to store
provide(MetaInj, meta)
provide(ActiveViewInj, activeView)

Loading…
Cancel
Save