Fix selecting all rows and fix table click events clashing with row selection
This commit is contained in:
parent
c4dcd29dc3
commit
04624ece07
|
@ -219,14 +219,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleSelectAll = e => {
|
const toggleSelectAll = e => {
|
||||||
if (e.detail) {
|
const select = !!e.detail
|
||||||
selectedRows = [...selectedRows, ...rows]
|
if (select) {
|
||||||
|
// Add any rows which are not already in selected rows
|
||||||
|
rows.forEach(row => {
|
||||||
|
if (selectedRows.findIndex(x => x._id === row._id) === -1) {
|
||||||
|
selectedRows.push(row)
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
//remove every object from selectedRows that is not in rows
|
// Remove any rows from selected rows that are in the current data set
|
||||||
let filtered = selectedRows.filter(el =>
|
selectedRows = selectedRows.filter(el =>
|
||||||
rows.every(f => f._id !== el._id)
|
rows.every(f => f._id !== el._id)
|
||||||
)
|
)
|
||||||
selectedRows = filtered
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,13 +340,16 @@
|
||||||
{#if showEditColumn}
|
{#if showEditColumn}
|
||||||
<div
|
<div
|
||||||
class="spectrum-Table-cell spectrum-Table-cell--divider spectrum-Table-cell--edit"
|
class="spectrum-Table-cell spectrum-Table-cell--divider spectrum-Table-cell--edit"
|
||||||
|
on:click={e => {
|
||||||
|
toggleSelectRow(row)
|
||||||
|
e.stopPropagation()
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<SelectEditRenderer
|
<SelectEditRenderer
|
||||||
data={row}
|
data={row}
|
||||||
selected={selectedRows.findIndex(
|
selected={selectedRows.findIndex(
|
||||||
selectedRow => selectedRow._id === row._id
|
selectedRow => selectedRow._id === row._id
|
||||||
) !== -1}
|
) !== -1}
|
||||||
onToggleSelection={() => toggleSelectRow(row)}
|
|
||||||
onEdit={e => editRow(e, row)}
|
onEdit={e => editRow(e, row)}
|
||||||
{allowSelectRows}
|
{allowSelectRows}
|
||||||
{allowEditRows}
|
{allowEditRows}
|
||||||
|
|
Loading…
Reference in New Issue