Browse Source

enhancement(gui): if record not found show error message and redirect to view

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3655/head
Pranav C 2 years ago
parent
commit
3c1476ffcf
  1. 14
      packages/nc-gui/components/smartsheet/expanded-form/index.vue

14
packages/nc-gui/components/smartsheet/expanded-form/index.vue

@ -1,4 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { message } from 'ant-design-vue'
import type { TableType, ViewType } from 'nocodb-sdk' import type { TableType, ViewType } from 'nocodb-sdk'
import { UITypes, isSystemColumn, isVirtualCol } from 'nocodb-sdk' import { UITypes, isSystemColumn, isVirtualCol } from 'nocodb-sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
@ -6,6 +7,7 @@ import Cell from '../Cell.vue'
import VirtualCell from '../VirtualCell.vue' import VirtualCell from '../VirtualCell.vue'
import Comments from './Comments.vue' import Comments from './Comments.vue'
import Header from './Header.vue' import Header from './Header.vue'
import { useRouter } from '#app'
import { import {
FieldsInj, FieldsInj,
IsFormInj, IsFormInj,
@ -42,6 +44,8 @@ const state = toRef(props, 'state')
const meta = toRef(props, 'meta') const meta = toRef(props, 'meta')
const router = useRouter()
const fields = computedInject(FieldsInj, (_fields) => { const fields = computedInject(FieldsInj, (_fields) => {
if (props.useMetaFields) { if (props.useMetaFields) {
return (meta.value.columns ?? []).filter((col) => !isSystemColumn(col)) return (meta.value.columns ?? []).filter((col) => !isSystemColumn(col))
@ -58,7 +62,15 @@ if (props.loadRow) {
} }
if (props.rowId) { if (props.rowId) {
await loadRow(props.rowId) try {
await loadRow(props.rowId)
} catch (e) {
if (e.response?.status === 404) {
// todo: i18n
message.error('Record not found')
router.replace({ query: {} })
} else throw e
}
} }
useProvideSmartsheetStore(ref({}) as Ref<ViewType>, meta) useProvideSmartsheetStore(ref({}) as Ref<ViewType>, meta)

Loading…
Cancel
Save