add row selection numbers
This commit is contained in:
parent
8fc10b3341
commit
a9194be9d2
|
@ -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,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);
|
||||
}
|
||||
|
|
|
@ -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