From fb47ef6c2fec48aee828302a6992150ec634ed3a Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 14 Sep 2020 16:18:02 +0100 Subject: [PATCH] fix pagination --- .../database/DataTable/ModelDataTable.svelte | 14 +++++++------- .../src/components/database/DataTable/Table.svelte | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/builder/src/components/database/DataTable/ModelDataTable.svelte b/packages/builder/src/components/database/DataTable/ModelDataTable.svelte index af99b2bada..0804b5e8da 100644 --- a/packages/builder/src/components/database/DataTable/ModelDataTable.svelte +++ b/packages/builder/src/components/database/DataTable/ModelDataTable.svelte @@ -36,14 +36,14 @@ } } - $: paginatedData = data - ? data.slice( + $: sort = $backendUiStore.sort + $: sorted = sort ? fsort(data)[sort.direction](sort.column) : data + $: paginatedData = sorted + ? sorted.slice( currentPage * ITEMS_PER_PAGE, currentPage * ITEMS_PER_PAGE + ITEMS_PER_PAGE ) : [] - $: sort = $backendUiStore.sort - $: sorted = sort ? fsort(data)[sort.direction](sort.column) : data $: headers = Object.keys($backendUiStore.selectedModel.schema) .sort() @@ -78,10 +78,10 @@ - {#if sorted.length === 0} + {#if paginatedData.length === 0}
No Data.
{/if} - {#each sorted as row} + {#each paginatedData as row} @@ -100,7 +100,7 @@ diff --git a/packages/builder/src/components/database/DataTable/Table.svelte b/packages/builder/src/components/database/DataTable/Table.svelte index 47be4eab37..d3fdc63046 100644 --- a/packages/builder/src/components/database/DataTable/Table.svelte +++ b/packages/builder/src/components/database/DataTable/Table.svelte @@ -26,15 +26,15 @@ $: columns = schema ? Object.keys(schema) : [] + $: sort = $backendUiStore.sort + $: sorted = sort ? fsort(data)[sort.direction](sort.column) : data $: paginatedData = - data && data.length - ? data.slice( + sorted && sorted.length + ? sorted.slice( currentPage * ITEMS_PER_PAGE, currentPage * ITEMS_PER_PAGE + ITEMS_PER_PAGE ) : [] - $: sort = $backendUiStore.sort - $: sorted = sort ? fsort(data)[sort.direction](sort.column) : data
@@ -68,7 +68,7 @@