Update delete rows button to be configurable

This commit is contained in:
Andrew Kingston 2022-08-02 16:44:37 +01:00
parent e8fa134c7c
commit 9a442cb0ce
2 changed files with 11 additions and 3 deletions

View File

@ -5,6 +5,7 @@
export let selectedRows
export let deleteRows
export let item = "row"
const dispatch = createEventDispatcher()
let modal
@ -14,12 +15,14 @@
modal?.hide()
dispatch("updaterows")
}
$: text = `${item}${selectedRows?.length === 1 ? "" : "s"}`
</script>
<Button icon="Delete" size="s" primary quiet on:click={modal.show}>
Delete
{selectedRows.length}
row(s)
{text}
</Button>
<ConfirmDialog
bind:this={modal}
@ -29,5 +32,5 @@
>
Are you sure you want to delete
{selectedRows.length}
row{selectedRows.length > 1 ? "s" : ""}?
{text}?
</ConfirmDialog>

View File

@ -240,7 +240,12 @@
<div class="controls-right">
<Search bind:value={searchEmail} placeholder="Search email" />
{#if selectedRows.length > 0}
<DeleteRowsButton on:updaterows {selectedRows} {deleteRows} />
<DeleteRowsButton
item="user"
on:updaterows
{selectedRows}
{deleteRows}
/>
{/if}
</div>
</div>