2020-10-28 02:04:32 +13:00
|
|
|
<script>
|
2021-09-30 00:07:35 +13:00
|
|
|
import { createEventDispatcher } from "svelte"
|
2021-06-16 06:36:56 +12:00
|
|
|
import { Button } from "@budibase/bbui"
|
2020-10-29 04:20:56 +13:00
|
|
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
2020-10-28 02:04:32 +13:00
|
|
|
|
|
|
|
export let selectedRows
|
|
|
|
export let deleteRows
|
2022-08-03 03:44:37 +12:00
|
|
|
export let item = "row"
|
2020-10-28 02:04:32 +13:00
|
|
|
|
2021-09-30 00:07:35 +13:00
|
|
|
const dispatch = createEventDispatcher()
|
2020-10-28 02:04:32 +13:00
|
|
|
let modal
|
|
|
|
|
|
|
|
async function confirmDeletion() {
|
|
|
|
await deleteRows()
|
2021-06-12 06:54:47 +12:00
|
|
|
modal?.hide()
|
2021-09-30 00:07:35 +13:00
|
|
|
dispatch("updaterows")
|
2020-10-28 02:04:32 +13:00
|
|
|
}
|
2022-08-03 03:44:37 +12:00
|
|
|
|
|
|
|
$: text = `${item}${selectedRows?.length === 1 ? "" : "s"}`
|
2020-10-28 02:04:32 +13:00
|
|
|
</script>
|
|
|
|
|
2022-11-07 11:35:33 +13:00
|
|
|
<Button icon="Delete" size="s" warning quiet on:click={modal.show}>
|
2021-04-09 04:10:18 +12:00
|
|
|
Delete
|
|
|
|
{selectedRows.length}
|
2022-08-03 03:44:37 +12:00
|
|
|
{text}
|
2021-04-09 04:10:18 +12:00
|
|
|
</Button>
|
2020-10-29 04:20:56 +13:00
|
|
|
<ConfirmDialog
|
|
|
|
bind:this={modal}
|
|
|
|
okText="Delete"
|
|
|
|
onOk={confirmDeletion}
|
2021-05-04 22:04:42 +12:00
|
|
|
title="Confirm Deletion"
|
|
|
|
>
|
2020-10-29 04:20:56 +13:00
|
|
|
Are you sure you want to delete
|
|
|
|
{selectedRows.length}
|
2022-08-03 03:44:37 +12:00
|
|
|
{text}?
|
2020-10-29 04:20:56 +13:00
|
|
|
</ConfirmDialog>
|