Fix table selection defaulting to true, reset selected rows when unmounting tables, remove position absolute on row selection text

This commit is contained in:
Andrew Kingston 2022-02-24 09:15:37 +00:00
parent 04624ece07
commit defe725bcc
1 changed files with 12 additions and 6 deletions

View File

@ -3,6 +3,7 @@
import { Table } from "@budibase/bbui"
import SlotRenderer from "./SlotRenderer.svelte"
import { UnsortableTypes } from "../../../constants"
import { onDestroy } from "svelte"
export let dataProvider
export let columns
@ -38,13 +39,13 @@
dataProvider?.id,
ActionTypes.SetDataProviderSorting
)
$: {
rowSelectionStore.actions.updateSelection(
$component.id,
selectedRows.map(row => row._id)
)
}
const getFields = (schema, customColumns, showAutoColumns) => {
// Check for an invalid column selection
let invalid = false
@ -125,6 +126,10 @@
const split = linkURL.split("/:")
routeStore.actions.navigate(`${split[0]}/${id}`, linkPeek)
}
onDestroy(() => {
rowSelectionStore.actions.updateSelection($component.id, [])
})
</script>
<div use:styleable={$component.styles} class={size}>
@ -136,7 +141,7 @@
{quiet}
{compact}
{customRenderers}
{allowSelectRows}
allowSelectRows={!!allowSelectRows}
bind:selectedRows
allowEditRows={false}
allowEditColumns={false}
@ -148,8 +153,10 @@
>
<slot />
</Table>
{#if allowSelectRows}
<div class="row-count">{selectedRows.length} record(s) selected</div>
{#if allowSelectRows && selectedRows.length}
<div class="row-count">
{selectedRows.length} row{selectedRows.length === 1 ? "" : "s"} selected
</div>
{/if}
</div>
@ -159,7 +166,6 @@
}
.row-count {
margin-top: calc(1.4 * var(--spacing-xl));
position: absolute;
margin-top: var(--spacing-l);
}
</style>