Browse Source

Merge pull request #6553 from nocodb/fix/stay-on-erd-while-table-change

Stay on erd while table change
pull/6557/head
Muhammed Mustafa 1 year ago committed by GitHub
parent
commit
d1da05df1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      packages/nc-gui/components/dashboard/TreeView/ViewsList.vue
  2. 18
      packages/nc-gui/composables/useTableNew.ts
  3. 37
      packages/nc-gui/store/views.ts

1
packages/nc-gui/components/dashboard/TreeView/ViewsList.vue

@ -192,6 +192,7 @@ async function changeView(view: ViewType) {
tableId: table.value.id!,
baseId: base.value.id!,
hardReload: view.type === ViewTypes.FORM && selected.value[0] === view.id,
doNotSwitchTab: true,
})
if (isMobileMode.value) {

18
packages/nc-gui/composables/useTableNew.ts

@ -49,6 +49,8 @@ export function useTableNew(param: { onTableCreate?: (tableMeta: TableType) => v
const { loadTables, baseUrl, isXcdbBase } = useBase()
const { openedViewsTab, viewsByTable } = storeToRefs(useViewsStore())
const workspaceId = computed(() => route.value.params.typeOrId as string)
const tables = computed(() => baseTables.value.get(param.baseId) || [])
@ -84,10 +86,18 @@ export function useTableNew(param: { onTableCreate?: (tableMeta: TableType) => v
tableId: table.id,
})
await navigateTo({
path: `/${workspaceIdOrType}/${baseIdOrBaseId}/${table?.id}`,
query: route.value.query,
})
const views = viewsByTable.value.get(table.id as string) ?? []
if (openedViewsTab.value !== 'view' && views[0].id) {
await navigateTo({
path: `/${workspaceIdOrType}/${baseIdOrBaseId}/${table?.id}/${views[0].id}/${openedViewsTab.value}`,
query: route.value.query,
})
} else
await navigateTo({
path: `/${workspaceIdOrType}/${baseIdOrBaseId}/${table?.id}`,
query: route.value.query,
})
await getMeta(table.id as string)
}

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

@ -154,13 +154,15 @@ export const useViewsStore = defineStore('viewsStore', () => {
baseId,
tableId,
hardReload,
doNotSwitchTab,
}: {
view: ViewType
baseId: string
tableId: string
hardReload?: boolean
doNotSwitchTab?: boolean
}) => {
const routeName = 'index-typeOrId-baseId-index-index-viewId-viewTitle'
const routeName = 'index-typeOrId-baseId-index-index-viewId-viewTitle-slugs'
let baseIdOrBaseId = baseId
@ -168,6 +170,8 @@ export const useViewsStore = defineStore('viewsStore', () => {
baseIdOrBaseId = route.value.params.baseId as string
}
const slugs = doNotSwitchTab ? router.currentRoute.value.params.slugs : undefined
if (
router.currentRoute.value.query &&
router.currentRoute.value.query.page &&
@ -175,11 +179,24 @@ export const useViewsStore = defineStore('viewsStore', () => {
) {
await router.push({
name: routeName,
params: { viewTitle: view.id || '', viewId: tableId, baseId: baseIdOrBaseId },
params: {
viewTitle: view.id || '',
viewId: tableId,
baseId: baseIdOrBaseId,
slugs,
},
query: router.currentRoute.value.query,
})
} else {
await router.push({ name: routeName, params: { viewTitle: view.id || '', viewId: tableId, baseId: baseIdOrBaseId } })
await router.push({
name: routeName,
params: {
viewTitle: view.id || '',
viewId: tableId,
baseId: baseIdOrBaseId,
slugs,
},
})
}
if (hardReload) {
@ -187,13 +204,23 @@ export const useViewsStore = defineStore('viewsStore', () => {
.replace({
name: routeName,
query: { reload: 'true' },
params: { viewId: tableId, baseId: baseIdOrBaseId, viewTitle: view.id || '' },
params: {
viewId: tableId,
baseId: baseIdOrBaseId,
viewTitle: view.id || '',
slugs,
},
})
.then(() => {
router.replace({
name: routeName,
query: {},
params: { viewId: tableId, viewTitle: view.id || '', baseId: baseIdOrBaseId },
params: {
viewId: tableId,
viewTitle: view.id || '',
baseId: baseIdOrBaseId,
slugs,
},
})
})
}

Loading…
Cancel
Save