add row selection numbers
This commit is contained in:
parent
1dd909c8c2
commit
340c9480c2
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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,14 +140,19 @@
|
|||
<slot />
|
||||
{/if}
|
||||
{#if paginate && $fetch.supportsPagination}
|
||||
<div class="pagination">
|
||||
<Pagination
|
||||
page={$fetch.pageNumber + 1}
|
||||
hasPrevPage={$fetch.hasPrevPage}
|
||||
hasNextPage={$fetch.hasNextPage}
|
||||
goToPrevPage={fetch.prevPage}
|
||||
goToNextPage={fetch.nextPage}
|
||||
/>
|
||||
<div class="footer">
|
||||
<div class="rowSelection">
|
||||
{$rowSelectionStore.length} record(s) selected
|
||||
</div>
|
||||
<div>
|
||||
<Pagination
|
||||
page={$fetch.pageNumber + 1}
|
||||
hasPrevPage={$fetch.hasPrevPage}
|
||||
hasNextPage={$fetch.hasNextPage}
|
||||
goToPrevPage={fetch.prevPage}
|
||||
goToNextPage={fetch.nextPage}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,8 @@ const createRowSelectionStore = () => {
|
|||
const store = writable([])
|
||||
|
||||
function update(rows) {
|
||||
console.log(rows)
|
||||
store.update(state => {
|
||||
state = rows
|
||||
state = [...rows]
|
||||
return state
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue