Browse Source

fix(nc-gui): include offset in fetchSharedViewData

pull/4848/head
Wing-Kam Wong 2 years ago
parent
commit
8b84a76bcb
  1. 3
      packages/nc-gui/composables/useKanbanViewStore.ts
  2. 19
      packages/nc-gui/composables/useSharedView.ts

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

@ -145,8 +145,7 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState(
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), ...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }),
where, where,
}) })
: // TODO: add range : await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value, offset: params.offset })
await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value })
formattedData.value.set(stackTitle, [...formattedData.value.get(stackTitle)!, ...formatData(response.list)]) formattedData.value.set(stackTitle, [...formattedData.value.get(stackTitle)!, ...formatData(response.list)])
} }

19
packages/nc-gui/composables/useSharedView.ts

@ -93,16 +93,27 @@ export function useSharedView() {
Object.keys(relatedMetas).forEach((key) => setMeta(relatedMetas[key])) Object.keys(relatedMetas).forEach((key) => setMeta(relatedMetas[key]))
} }
const fetchSharedViewData = async ({ sortsArr, filtersArr }: { sortsArr: SortType[]; filtersArr: FilterType[] }) => { const fetchSharedViewData = async ({
sortsArr,
filtersArr,
offset,
}: {
sortsArr: SortType[]
filtersArr: FilterType[]
offset?: number
}) => {
if (!sharedView.value) return if (!sharedView.value) return
const page = paginationData.value.page || 1 if (!offset) {
const pageSize = paginationData.value.pageSize || appInfoDefaultLimit const page = paginationData.value.page || 1
const pageSize = paginationData.value.pageSize || appInfoDefaultLimit
offset = (page - 1) * pageSize
}
const { data } = await $api.public.dataList( const { data } = await $api.public.dataList(
sharedView.value.uuid!, sharedView.value.uuid!,
{ {
offset: (page - 1) * pageSize, offset,
filterArrJson: JSON.stringify(filtersArr ?? nestedFilters.value), filterArrJson: JSON.stringify(filtersArr ?? nestedFilters.value),
sortArrJson: JSON.stringify(sortsArr ?? sorts.value), sortArrJson: JSON.stringify(sortsArr ?? sorts.value),
} as any, } as any,

Loading…
Cancel
Save