Browse Source

feat(nc-gui): infinite scroll to load

pull/3818/head
Wing-Kam Wong 2 years ago
parent
commit
93858b018d
  1. 12
      packages/nc-gui/components/smartsheet/Kanban.vue

12
packages/nc-gui/components/smartsheet/Kanban.vue

@ -33,6 +33,7 @@ const expandedFormRowState = ref<Record<string, any>>()
const {
loadKanbanData,
loadMoreKanbanData,
loadKanbanMeta,
kanbanMetaData,
formattedData,
@ -46,6 +47,8 @@ const {
const { isUIAllowed } = useUIPermission()
const { appInfo } = $(useGlobal())
provide(IsFormInj, ref(false))
provide(IsGalleryInj, ref(false))
provide(IsGridInj, ref(false))
@ -146,9 +149,10 @@ async function onMove(event: any, stackKey: string) {
const kanbanListScrollHandler = async (e: any) => {
if (e.target.scrollTop + e.target.clientHeight >= e.target.scrollHeight) {
const stackId = e.target.getAttribute('data-id')
// TODO: load 25 more records
console.log(stackId)
const stackTitle = e.target.getAttribute('data-stack-title')
const pageSize = appInfo.defaultLimit || 25
const page = Math.ceil(formattedData.value[stackTitle].length / pageSize)
await loadMoreKanbanData(stackTitle, { offset: (page - 1) * pageSize })
}
}
@ -193,7 +197,7 @@ openNewRecordFormHook?.on(async () => {
<div class="nc-kanban-stack-head text-slate-500 font-bold">{{ stack.title }}</div>
</a-layout-header>
<a-layout-content class="overflow-y-hidden">
<div :ref="kanbanListRef" class="nc-kanban-list h-full overflow-y-auto" :data-id="stack.id">
<div :ref="kanbanListRef" class="nc-kanban-list h-full overflow-y-auto" :data-stack-title="stack.title">
<Draggable
v-model="formattedData[stack.title]"
item-key="row.Id"

Loading…
Cancel
Save