add row selection numbers

This commit is contained in:
Peter Clement 2022-02-16 15:00:18 +00:00
parent 8fc10b3341
commit a9194be9d2
3 changed files with 22 additions and 17 deletions

View File

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

View File

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

View File

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