Browse Source

fix: handle group by load method exceptions

pull/7787/head
Pranav C 9 months ago
parent
commit
dcbaeffe7e
  1. 10
      packages/nc-gui/composables/useViewGroupBy.ts

10
packages/nc-gui/composables/useViewGroupBy.ts

@ -1,5 +1,7 @@
import { type ColumnType, type SelectOptionsType, UITypes, type ViewType } from 'nocodb-sdk' import { type ColumnType, type SelectOptionsType, UITypes, type ViewType } from 'nocodb-sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import { message } from 'ant-design-vue'
import { extractSdkResponseErrorMsg } from '../utils'
import { GROUP_BY_VARS, ref, storeToRefs, useApi, useBase, useViewColumnsOrThrow } from '#imports' import { GROUP_BY_VARS, ref, storeToRefs, useApi, useBase, useViewColumnsOrThrow } from '#imports'
import type { Group, GroupNestedIn, Row } from '#imports' import type { Group, GroupNestedIn, Row } from '#imports'
@ -178,6 +180,7 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
} }
async function loadGroups(params: any = {}, group?: Group) { async function loadGroups(params: any = {}, group?: Group) {
try {
group = group || rootGroup.value group = group || rootGroup.value
if (!base?.value?.id || !view.value?.id || !view.value?.fk_model_id || !group) return if (!base?.value?.id || !view.value?.id || !view.value?.fk_model_id || !group) return
@ -293,9 +296,13 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
if (expectedPage < group.paginationData.page!) { if (expectedPage < group.paginationData.page!) {
await groupWrapperChangePage(expectedPage, group) await groupWrapperChangePage(expectedPage, group)
} }
} catch (e) {
message.error(await extractSdkResponseErrorMsg(e))
}
} }
async function loadGroupData(group: Group, force = false, params: any = {}) { async function loadGroupData(group: Group, force = false, params: any = {}) {
try {
if (!base?.value?.id || !view.value?.id || !view.value?.fk_model_id) return if (!base?.value?.id || !view.value?.id || !view.value?.fk_model_id) return
if (group.children && !force) return if (group.children && !force) return
@ -324,6 +331,9 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
group.count = response.pageInfo.totalRows ?? 0 group.count = response.pageInfo.totalRows ?? 0
group.rows = formatData(response.list) group.rows = formatData(response.list)
group.paginationData = response.pageInfo group.paginationData = response.pageInfo
} catch (e) {
message.error(await extractSdkResponseErrorMsg(e))
}
} }
const loadGroupPage = async (group: Group, p: number) => { const loadGroupPage = async (group: Group, p: number) => {

Loading…
Cancel
Save