Browse Source

Merge pull request #3367 from nocodb/fix/3366-update-route-on-active-view-delete

fix(gui-v2): navigate to default view if active view deleted
pull/3375/head
Pranav C 2 years ago committed by GitHub
parent
commit
8249d4dbaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      packages/nc-gui-v2/components.d.ts
  2. 12
      packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue
  3. 17
      packages/nc-gui-v2/composables/useViewData.ts

1
packages/nc-gui-v2/components.d.ts vendored

@ -170,6 +170,7 @@ declare module '@vue/runtime-core' {
MdiInformation: typeof import('~icons/mdi/information')['default']
MdiJson: typeof import('~icons/mdi/json')['default']
MdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default']
MdiKeyChange: typeof import('~icons/mdi/key-change')['default']
MdiKeyPlus: typeof import('~icons/mdi/key-plus')['default']
MdiKeyStar: typeof import('~icons/mdi/key-star')['default']
MdiLink: typeof import('~icons/mdi/link')['default']

12
packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue

@ -24,7 +24,9 @@ import DlgViewDelete from '~/components/dlg/ViewDelete.vue'
interface Emits {
(event: 'openModal', data: { type: ViewTypes; title?: string; copyViewId?: string }): void
(event: 'deleted'): void
(event: 'sorted'): void
}
@ -186,8 +188,14 @@ function openDeleteDialog(view: Record<string, any>) {
closeDialog()
emits('deleted')
// return to the default view
activeView.value = views.value[0]
if (activeView.value === view) {
// return to the default view
router.replace({
params: {
viewTitle: views.value[0].title,
},
})
}
},
})

17
packages/nc-gui-v2/composables/useViewData.ts

@ -8,9 +8,9 @@ import {
extractPkFromRow,
extractSdkResponseErrorMsg,
getHTMLEncodedText,
useApi,
useProject,
useUIPermission,
useApi
} from '#imports'
const formatData = (list: Record<string, any>[]) =>
@ -118,11 +118,11 @@ export function useViewData(
if ((!project?.value?.id || !meta?.value?.id || !viewMeta?.value?.id) && !isPublic.value) return
const response = !isPublic.value
? await api.dbViewRow.list('noco', project.value.id!, meta.value.id!, viewMeta!.value.id, {
...params,
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }),
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }),
where: where?.value,
})
...params,
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }),
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }),
where: where?.value,
})
: await fetchSharedViewData()
formattedData.value = formatData(response.list)
paginationData.value = response.pageInfo
@ -193,8 +193,7 @@ export function useViewData(
value: getHTMLEncodedText(toUpdate.row[property]),
prev_value: getHTMLEncodedText(toUpdate.oldRow[property]),
})
.then(() => {
})
.then(() => {})
/** update row data(to sync formula and other related columns) */
Object.assign(toUpdate.row, updatedRowData)
@ -236,7 +235,7 @@ export function useViewData(
const deleteRowById = async (id: string) => {
if (!id) {
throw new Error('Delete not allowed for table which doesn\'t have primary Key')
throw new Error("Delete not allowed for table which doesn't have primary Key")
}
const res: any = await $api.dbViewRow.delete(

Loading…
Cancel
Save