add row selection numbers

This commit is contained in:
Peter Clement 2022-02-16 15:00:18 +00:00
parent 1dd909c8c2
commit 340c9480c2
3 changed files with 22 additions and 17 deletions

View File

@ -31,7 +31,6 @@
export let disableSorting = false export let disableSorting = false
export let allowSelectAllRows = false export let allowSelectAllRows = false
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
// Config // Config
const rowHeight = 55 const rowHeight = 55
const headerHeight = 36 const headerHeight = 36
@ -219,9 +218,10 @@
if (!allowSelectRows) { if (!allowSelectRows) {
return return
} }
if ( if (selectedRows.some(selectedRow => selectedRow._id === row._id)) {
selectedRows.findIndex(selectedRow => selectedRow._id === row._id) === 0 console.log("hello")
) { console.log(row)
selectedRows = selectedRows.filter( selectedRows = selectedRows.filter(
selectedRow => selectedRow._id !== row._id selectedRow => selectedRow._id !== row._id
) )

View File

@ -11,7 +11,8 @@
export let limit export let limit
export let paginate export let paginate
const { styleable, Provider, ActionTypes, API } = getContext("sdk") const { styleable, Provider, ActionTypes, API, rowSelectionStore } =
getContext("sdk")
const component = getContext("component") const component = getContext("component")
// We need to manage our lucene query manually as we want to allow components // We need to manage our lucene query manually as we want to allow components
@ -139,14 +140,19 @@
<slot /> <slot />
{/if} {/if}
{#if paginate && $fetch.supportsPagination} {#if paginate && $fetch.supportsPagination}
<div class="pagination"> <div class="footer">
<Pagination <div class="rowSelection">
page={$fetch.pageNumber + 1} {$rowSelectionStore.length} record(s) selected
hasPrevPage={$fetch.hasPrevPage} </div>
hasNextPage={$fetch.hasNextPage} <div>
goToPrevPage={fetch.prevPage} <Pagination
goToNextPage={fetch.nextPage} page={$fetch.pageNumber + 1}
/> hasPrevPage={$fetch.hasPrevPage}
hasNextPage={$fetch.hasNextPage}
goToPrevPage={fetch.prevPage}
goToNextPage={fetch.nextPage}
/>
</div>
</div> </div>
{/if} {/if}
{/if} {/if}
@ -167,10 +173,10 @@
align-items: center; align-items: center;
height: 100px; height: 100px;
} }
.pagination { .footer {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: flex-end; justify-content: space-between;
align-items: center; align-items: center;
margin-top: var(--spacing-xl); margin-top: var(--spacing-xl);
} }

View File

@ -4,9 +4,8 @@ const createRowSelectionStore = () => {
const store = writable([]) const store = writable([])
function update(rows) { function update(rows) {
console.log(rows)
store.update(state => { store.update(state => {
state = rows state = [...rows]
return state return state
}) })
} }