fix pagination
This commit is contained in:
parent
44fcec5cc2
commit
fb47ef6c2f
|
@ -36,14 +36,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: paginatedData = data
|
$: sort = $backendUiStore.sort
|
||||||
? data.slice(
|
$: sorted = sort ? fsort(data)[sort.direction](sort.column) : data
|
||||||
|
$: paginatedData = sorted
|
||||||
|
? sorted.slice(
|
||||||
currentPage * ITEMS_PER_PAGE,
|
currentPage * ITEMS_PER_PAGE,
|
||||||
currentPage * ITEMS_PER_PAGE + 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)
|
$: headers = Object.keys($backendUiStore.selectedModel.schema)
|
||||||
.sort()
|
.sort()
|
||||||
|
@ -78,10 +78,10 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#if sorted.length === 0}
|
{#if paginatedData.length === 0}
|
||||||
<div class="no-data">No Data.</div>
|
<div class="no-data">No Data.</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#each sorted as row}
|
{#each paginatedData as row}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<EditRowPopover {row} />
|
<EditRowPopover {row} />
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
<TablePagination
|
<TablePagination
|
||||||
{data}
|
{data}
|
||||||
bind:currentPage
|
bind:currentPage
|
||||||
pageItemCount={data.length}
|
pageItemCount={paginatedData.length}
|
||||||
{ITEMS_PER_PAGE} />
|
{ITEMS_PER_PAGE} />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
@ -26,15 +26,15 @@
|
||||||
|
|
||||||
$: columns = schema ? Object.keys(schema) : []
|
$: columns = schema ? Object.keys(schema) : []
|
||||||
|
|
||||||
|
$: sort = $backendUiStore.sort
|
||||||
|
$: sorted = sort ? fsort(data)[sort.direction](sort.column) : data
|
||||||
$: paginatedData =
|
$: paginatedData =
|
||||||
data && data.length
|
sorted && sorted.length
|
||||||
? data.slice(
|
? sorted.slice(
|
||||||
currentPage * ITEMS_PER_PAGE,
|
currentPage * ITEMS_PER_PAGE,
|
||||||
currentPage * ITEMS_PER_PAGE + ITEMS_PER_PAGE
|
currentPage * ITEMS_PER_PAGE + ITEMS_PER_PAGE
|
||||||
)
|
)
|
||||||
: []
|
: []
|
||||||
$: sort = $backendUiStore.sort
|
|
||||||
$: sorted = sort ? fsort(data)[sort.direction](sort.column) : data
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
<TablePagination
|
<TablePagination
|
||||||
{data}
|
{data}
|
||||||
bind:currentPage
|
bind:currentPage
|
||||||
pageItemCount={data.length}
|
pageItemCount={paginatedData.length}
|
||||||
{ITEMS_PER_PAGE} />
|
{ITEMS_PER_PAGE} />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue