Fix navigation on deleting views and use ConfirmDialog for view deletion to improve consistency
This commit is contained in:
parent
9a2d52c9fe
commit
4e3be6b7b7
|
@ -1,20 +1,19 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { goto } from "@sveltech/routify"
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
import { backendUiStore } from "builderStore"
|
import { backendUiStore } from "builderStore"
|
||||||
import { notifier } from "builderStore/store/notifications"
|
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 DeleteViewModal from "components/database/DataTable/modals/DeleteView.svelte"
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
||||||
|
|
||||||
const { open, close } = getContext("simple-modal")
|
|
||||||
|
|
||||||
export let view
|
export let view
|
||||||
|
|
||||||
let anchor
|
let anchor
|
||||||
let dropdown
|
let dropdown
|
||||||
|
|
||||||
let editing
|
let editing
|
||||||
let originalName = view.name
|
let originalName = view.name
|
||||||
|
let confirmDeleteDialog
|
||||||
|
|
||||||
function showEditor() {
|
function showEditor() {
|
||||||
editing = true
|
editing = true
|
||||||
|
@ -26,31 +25,28 @@
|
||||||
close()
|
close()
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteView = () => {
|
async function save() {
|
||||||
open(
|
await backendUiStore.actions.views.save({
|
||||||
DeleteViewModal,
|
|
||||||
{
|
|
||||||
onClosed: close,
|
|
||||||
viewName: view.name,
|
|
||||||
},
|
|
||||||
{ styleContent: { padding: "0" } }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function save() {
|
|
||||||
backendUiStore.actions.views.save({
|
|
||||||
originalName,
|
originalName,
|
||||||
...view,
|
...view,
|
||||||
})
|
})
|
||||||
notifier.success("Renamed View Successfully.")
|
notifier.success("View renamed successfully")
|
||||||
hideEditor()
|
hideEditor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteView() {
|
||||||
|
const name = view.name
|
||||||
|
const id = view.modelId
|
||||||
|
await backendUiStore.actions.views.delete(name)
|
||||||
|
notifier.success("View deleted")
|
||||||
|
$goto(`./model/${id}`)
|
||||||
|
}
|
||||||
</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 View</h5>
|
<h5>Edit View</h5>
|
||||||
|
@ -70,13 +66,19 @@
|
||||||
<Icon name="edit" />
|
<Icon name="edit" />
|
||||||
Edit
|
Edit
|
||||||
</li>
|
</li>
|
||||||
<li data-cy="delete-view" on:click={deleteView}>
|
<li data-cy="delete-view" 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 view '${view.name}'? Your data will be deleted and this action cannot be undone.`}
|
||||||
|
okText="Delete View"
|
||||||
|
onOk={deleteView}
|
||||||
|
title="Confirm Delete" />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
div.icon {
|
div.icon {
|
||||||
|
@ -85,6 +87,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