Update delete rows button to be configurable
This commit is contained in:
parent
b838a66954
commit
e9df049e01
2 changed files with 11 additions and 3 deletions
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
export let selectedRows
|
export let selectedRows
|
||||||
export let deleteRows
|
export let deleteRows
|
||||||
|
export let item = "row"
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let modal
|
let modal
|
||||||
|
@ -14,12 +15,14 @@
|
||||||
modal?.hide()
|
modal?.hide()
|
||||||
dispatch("updaterows")
|
dispatch("updaterows")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: text = `${item}${selectedRows?.length === 1 ? "" : "s"}`
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Button icon="Delete" size="s" primary quiet on:click={modal.show}>
|
<Button icon="Delete" size="s" primary quiet on:click={modal.show}>
|
||||||
Delete
|
Delete
|
||||||
{selectedRows.length}
|
{selectedRows.length}
|
||||||
row(s)
|
{text}
|
||||||
</Button>
|
</Button>
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
bind:this={modal}
|
bind:this={modal}
|
||||||
|
@ -29,5 +32,5 @@
|
||||||
>
|
>
|
||||||
Are you sure you want to delete
|
Are you sure you want to delete
|
||||||
{selectedRows.length}
|
{selectedRows.length}
|
||||||
row{selectedRows.length > 1 ? "s" : ""}?
|
{text}?
|
||||||
</ConfirmDialog>
|
</ConfirmDialog>
|
||||||
|
|
|
@ -240,7 +240,12 @@
|
||||||
<div class="controls-right">
|
<div class="controls-right">
|
||||||
<Search bind:value={searchEmail} placeholder="Search email" />
|
<Search bind:value={searchEmail} placeholder="Search email" />
|
||||||
{#if selectedRows.length > 0}
|
{#if selectedRows.length > 0}
|
||||||
<DeleteRowsButton on:updaterows {selectedRows} {deleteRows} />
|
<DeleteRowsButton
|
||||||
|
item="user"
|
||||||
|
on:updaterows
|
||||||
|
{selectedRows}
|
||||||
|
{deleteRows}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue