Use ConfirmDialog for table deletion to improve consistency
This commit is contained in:
parent
72b8d387cc
commit
9a2d52c9fe
|
@ -1,18 +1,17 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
import { backendUiStore } from "builderStore"
|
import { backendUiStore } from "builderStore"
|
||||||
|
import { notifier } from "builderStore/store/notifications"
|
||||||
import { DropdownMenu, Button, Icon, Input, Select } from "@budibase/bbui"
|
import { DropdownMenu, Button, Icon, Input, Select } from "@budibase/bbui"
|
||||||
import { FIELDS } from "constants/backend"
|
import { FIELDS } from "constants/backend"
|
||||||
import DeleteTableModal from "components/database/DataTable/modals/DeleteTable.svelte"
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
||||||
|
|
||||||
const { open, close } = getContext("simple-modal")
|
|
||||||
|
|
||||||
export let table
|
export let table
|
||||||
|
|
||||||
let anchor
|
let anchor
|
||||||
let dropdown
|
let dropdown
|
||||||
|
|
||||||
let editing
|
let editing
|
||||||
|
let confirmDeleteDialog
|
||||||
|
|
||||||
function showEditor() {
|
function showEditor() {
|
||||||
editing = true
|
editing = true
|
||||||
|
@ -24,27 +23,22 @@
|
||||||
close()
|
close()
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteTable = () => {
|
async function deleteTable() {
|
||||||
open(
|
await backendUiStore.actions.models.delete(table)
|
||||||
DeleteTableModal,
|
notifier.success("Table deleted")
|
||||||
{
|
|
||||||
onClosed: close,
|
|
||||||
table,
|
|
||||||
},
|
|
||||||
{ styleContent: { padding: "0" } }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
async function save() {
|
||||||
backendUiStore.actions.models.save(table)
|
await backendUiStore.actions.models.save(table)
|
||||||
|
notifier.success("Table renamed successfully")
|
||||||
hideEditor()
|
hideEditor()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="icon" bind:this={anchor} on:click={dropdown.show}>
|
<div bind:this={anchor} class="icon" on:click={dropdown.show}>
|
||||||
<i class="ri-more-line" />
|
<i class="ri-more-line" />
|
||||||
</div>
|
</div>
|
||||||
<DropdownMenu bind:this={dropdown} {anchor} align="left">
|
<DropdownMenu align="left" {anchor} bind:this={dropdown}>
|
||||||
{#if editing}
|
{#if editing}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h5>Edit Table</h5>
|
<h5>Edit Table</h5>
|
||||||
|
@ -64,13 +58,19 @@
|
||||||
<Icon name="edit" />
|
<Icon name="edit" />
|
||||||
Edit
|
Edit
|
||||||
</li>
|
</li>
|
||||||
<li data-cy="delete-table" on:click={deleteTable}>
|
<li data-cy="delete-table" on:click={() => confirmDeleteDialog.show()}>
|
||||||
<Icon name="delete" />
|
<Icon name="delete" />
|
||||||
Delete
|
Delete
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{/if}
|
{/if}
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
<ConfirmDialog
|
||||||
|
bind:this={confirmDeleteDialog}
|
||||||
|
body={`Are you sure you wish to delete the table '${table.name}'? Your data will be deleted and this action cannot be undone.`}
|
||||||
|
okText="Delete Table"
|
||||||
|
onOk={deleteTable}
|
||||||
|
title="Confirm Delete" />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
div.icon {
|
div.icon {
|
||||||
|
@ -79,6 +79,7 @@
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.icon i {
|
div.icon i {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue