From dc85b4a9b0a451089c048e50a073002ca8190299 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 15 Sep 2022 12:57:31 +0800 Subject: [PATCH] feat(nc-gui): add loadMoreKanbanData --- .../nc-gui/composables/useKanbanViewData.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/composables/useKanbanViewData.ts b/packages/nc-gui/composables/useKanbanViewData.ts index 301d2e0736..6201983ebe 100644 --- a/packages/nc-gui/composables/useKanbanViewData.ts +++ b/packages/nc-gui/composables/useKanbanViewData.ts @@ -43,10 +43,7 @@ export function useKanbanViewData( rowMeta: {}, })) - async function loadKanbanData(params: Parameters['dbViewRow']['list']>[4] = {}) { - // each stack only loads 25 records -> scroll to load more (to be integrated with infinite scroll) - // TODO: integrate with infinite scroll - // TODO: handle share view case + async function loadKanbanData() { if ((!project?.value?.id || !meta?.value?.id || !viewMeta?.value?.id) && !isPublic.value) return // reset formattedData to avoid storing previous data after changing grouping field @@ -59,7 +56,6 @@ export function useKanbanViewData( where = `(${groupingField.value},is,null)` } const response = 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, @@ -69,6 +65,20 @@ export function useKanbanViewData( ) } + async function loadMoreKanbanData(stackTitle: string, params: Parameters['dbViewRow']['list']>[4] = {}) { + let where = `(${groupingField.value},eq,${stackTitle})` + if (stackTitle === 'Uncategorized') { + where = `(${groupingField.value},is,null)` + } + const response = 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, + }) + formattedData.value[stackTitle] = [...formattedData.value[stackTitle], ...formatData(response.list)] + } + async function loadKanbanMeta() { if (!viewMeta?.value?.id) return kanbanMetaData.value = await $api.dbView.kanbanRead(viewMeta.value.id) @@ -215,6 +225,7 @@ export function useKanbanViewData( return { loadKanbanData, + loadMoreKanbanData, loadKanbanMeta, updateKanbanMeta, kanbanMetaData,