Browse Source

fix(nc-gui): search data offset issue of gallery view & groupby

pull/7526/head
Ramesh Mane 9 months ago
parent
commit
ebfd837bf7
  1. 15
      packages/nc-gui/components/smartsheet/Gallery.vue
  2. 10
      packages/nc-gui/components/smartsheet/grid/GroupBy.vue
  3. 8
      packages/nc-gui/components/smartsheet/grid/GroupByTable.vue
  4. 2
      packages/nc-gui/components/smartsheet/grid/Table.vue
  5. 3
      packages/nc-gui/composables/useViewGroupBy.ts

15
packages/nc-gui/components/smartsheet/Gallery.vue

@ -174,9 +174,18 @@ reloadViewMetaHook?.on(async () => {
reloadAttachments.value = false
})
})
reloadViewDataHook?.on(async () => {
await loadData()
})
reloadViewDataHook?.on(
async (
params: void | {
shouldShowLoading?: boolean | undefined
offset?: number | undefined
},
) => {
await loadData({
...(params?.offset !== undefined ? { offset: params.offset } : {}),
})
},
)
// provide view data reload hook as fallback to row data reload
provide(ReloadRowDataHookInj, reloadViewDataHook)

10
packages/nc-gui/components/smartsheet/grid/GroupBy.vue

@ -12,7 +12,7 @@ const props = defineProps<{
group: Group
loadGroups: (params?: any, group?: Group) => Promise<void>
loadGroupData: (group: Group, force?: boolean) => Promise<void>
loadGroupData: (group: Group, force?: boolean, params?: any) => Promise<void>
loadGroupPage: (group: Group, p: number) => Promise<void>
groupWrapperChangePage: (page: number, groupWrapper?: Group) => Promise<void>
@ -80,11 +80,13 @@ const findAndLoadSubGroup = (key: any) => {
oldActiveGroups.value = key
}
const reloadViewDataHandler = () => {
const reloadViewDataHandler = (params: void | { shouldShowLoading?: boolean | undefined; offset?: number | undefined }) => {
if (vGroup.value.nested) {
props.loadGroups({}, vGroup.value)
props.loadGroups({ ...(params?.offset !== undefined ? { offset: params.offset } : {}) }, vGroup.value)
} else {
props.loadGroupData(vGroup.value, true)
props.loadGroupData(vGroup.value, true, {
...(params?.offset !== undefined ? { offset: params.offset } : {}),
})
}
}

8
packages/nc-gui/components/smartsheet/grid/GroupByTable.vue

@ -8,7 +8,7 @@ const props = defineProps<{
group: Group
loadGroups: (params?: any, group?: Group) => Promise<void>
loadGroupData: (group: Group, force?: boolean) => Promise<void>
loadGroupData: (group: Group, force?: boolean, params?: any) => Promise<void>
loadGroupPage: (group: Group, p: number) => Promise<void>
groupWrapperChangePage: (page: number, groupWrapper?: Group) => Promise<void>
@ -87,8 +87,10 @@ const { deleteRow, deleteSelectedRows, deleteRangeOfRows, updateOrSaveRow, bulkU
},
})
const reloadTableData = async () => {
await props.loadGroupData(vGroup.value, true)
const reloadTableData = async (params: void | { shouldShowLoading?: boolean | undefined; offset?: number | undefined }) => {
await props.loadGroupData(vGroup.value, true, {
...(params?.offset !== undefined ? { offset: params.offset } : {}),
})
}
onBeforeUnmount(async () => {

2
packages/nc-gui/components/smartsheet/grid/Table.vue

@ -56,7 +56,7 @@ import type { CellRange, Row } from '#imports'
const props = defineProps<{
data: Row[]
paginationData?: PaginatedType
loadData?: (params?: unknown) => Promise<void>
loadData?: (params?: any) => Promise<void>
changePage?: (page: number) => void
callAddEmptyRow?: (addAfter?: number) => Row | undefined
deleteRow?: (rowIndex: number, undo?: boolean) => Promise<void>

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

@ -295,7 +295,7 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
}
}
async function loadGroupData(group: Group, force = false) {
async function loadGroupData(group: Group, force = false, params: any = {}) {
if (!base?.value?.id || !view.value?.id || !view.value?.fk_model_id) return
if (group.children && !force) return
@ -315,6 +315,7 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
const response = !isPublic.value
? await api.dbViewRow.list('noco', base.value.id, view.value.fk_model_id, view.value.id, {
...query,
...params,
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }),
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }),
} as any)

Loading…
Cancel
Save