Skip to content

Commit

Permalink
fix(nc-gui): stay on erd while table change
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafapc19 committed Oct 3, 2023
1 parent 63e3b4d commit f6855d1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 14 additions & 4 deletions packages/nc-gui/composables/useTableNew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) || [])
Expand Down Expand Up @@ -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)
}
Expand Down
37 changes: 32 additions & 5 deletions packages/nc-gui/store/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,46 +154,73 @@ 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

if (['base'].includes(route.value.params.typeOrId as string)) {
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 &&
router.currentRoute.value.query.page === 'fields'
) {
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) {
await router
.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,
},
})
})
}
Expand Down

1 comment on commit f6855d1

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR changes have been deployed. Please run the following command to verify:

docker run -d -p 8888:8080 nocodb/nocodb-timely:0.111.4-pr-6553-20231003-1018

Please sign in to comment.