add row selection numbers
This commit is contained in:
parent
8fc10b3341
commit
a9194be9d2
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
|
@ -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,7 +140,11 @@
|
||||||
<slot />
|
<slot />
|
||||||
{/if}
|
{/if}
|
||||||
{#if paginate && $fetch.supportsPagination}
|
{#if paginate && $fetch.supportsPagination}
|
||||||
<div class="pagination">
|
<div class="footer">
|
||||||
|
<div class="rowSelection">
|
||||||
|
{$rowSelectionStore.length} record(s) selected
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
<Pagination
|
<Pagination
|
||||||
page={$fetch.pageNumber + 1}
|
page={$fetch.pageNumber + 1}
|
||||||
hasPrevPage={$fetch.hasPrevPage}
|
hasPrevPage={$fetch.hasPrevPage}
|
||||||
|
@ -148,6 +153,7 @@
|
||||||
goToNextPage={fetch.nextPage}
|
goToNextPage={fetch.nextPage}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</Provider>
|
</Provider>
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue