converts table dropdown to spectrum ActionMenu
This commit is contained in:
parent
47f6509baf
commit
65d6ca6b5d
|
@ -3,15 +3,23 @@
|
||||||
import { store, allScreens } from "builderStore"
|
import { store, allScreens } from "builderStore"
|
||||||
import { tables } from "stores/backend"
|
import { tables } from "stores/backend"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
import { Icon, Popover, Button, Input } from "@budibase/bbui"
|
import {
|
||||||
|
ActionMenu,
|
||||||
|
MenuItem,
|
||||||
|
Icon,
|
||||||
|
Modal,
|
||||||
|
ModalContent,
|
||||||
|
Popover,
|
||||||
|
Button,
|
||||||
|
Input,
|
||||||
|
} from "@budibase/bbui"
|
||||||
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
||||||
import { DropdownContainer, DropdownItem } from "components/common/Dropdowns"
|
|
||||||
|
|
||||||
export let table
|
export let table
|
||||||
|
|
||||||
let anchor
|
let anchor
|
||||||
|
let editorModal
|
||||||
let dropdown
|
let dropdown
|
||||||
let editing
|
|
||||||
let confirmDeleteDialog
|
let confirmDeleteDialog
|
||||||
let error = ""
|
let error = ""
|
||||||
let originalName = table.name
|
let originalName = table.name
|
||||||
|
@ -19,15 +27,16 @@
|
||||||
let willBeDeleted
|
let willBeDeleted
|
||||||
|
|
||||||
function showEditor() {
|
function showEditor() {
|
||||||
editing = true
|
editorModal.show()
|
||||||
|
dropdown?.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideEditor() {
|
function hideEditor() {
|
||||||
|
editorModal.hide()
|
||||||
dropdown?.hide()
|
dropdown?.hide()
|
||||||
editing = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showModal() {
|
function showDeleteModal() {
|
||||||
const screens = $allScreens
|
const screens = $allScreens
|
||||||
templateScreens = screens.filter(
|
templateScreens = screens.filter(
|
||||||
(screen) => screen.autoTableId === table._id
|
(screen) => screen.autoTableId === table._id
|
||||||
|
@ -60,50 +69,35 @@
|
||||||
function checkValid(evt) {
|
function checkValid(evt) {
|
||||||
const tableName = evt.target.value
|
const tableName = evt.target.value
|
||||||
error =
|
error =
|
||||||
originalName !== tableName
|
originalName === tableName
|
||||||
? `Table with name ${tableName} already exists. Please choose another name.`
|
? `Table with name ${tableName} already exists. Please choose another name.`
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div on:click|stopPropagation>
|
<ActionMenu bind:this={dropdown}>
|
||||||
<div bind:this={anchor} class="icon" on:click={dropdown.show}>
|
<div slot="button" class="icon" on:click={dropdown.show}>
|
||||||
<Icon s hoverable name="MoreSmallList" />
|
<Icon s hoverable name="MoreSmallList" />
|
||||||
</div>
|
</div>
|
||||||
<Popover align="left" {anchor} bind:this={dropdown}>
|
<MenuItem icon="Edit" on:click={showEditor}>Edit</MenuItem>
|
||||||
{#if editing}
|
<MenuItem icon="Delete" on:click={showDeleteModal}>Delete</MenuItem>
|
||||||
<div class="actions">
|
</ActionMenu>
|
||||||
<h5>Edit Table</h5>
|
|
||||||
<Input
|
<Modal bind:this={editorModal}>
|
||||||
label="Table Name"
|
<ModalContent
|
||||||
thin
|
title='Edit Table'
|
||||||
bind:value={table.name}
|
confirmText='Save'
|
||||||
on:input={checkValid}
|
onConfirm={save}
|
||||||
{error}
|
disabled={table.name === originalName || error}>
|
||||||
/>
|
<Input
|
||||||
<footer>
|
label="Table Name"
|
||||||
<Button secondary on:click={hideEditor}>Cancel</Button>
|
thin
|
||||||
<Button primary disabled={error} on:click={save}>Save</Button>
|
bind:value={table.name}
|
||||||
</footer>
|
on:input={checkValid}
|
||||||
</div>
|
{error}
|
||||||
{:else}
|
/>
|
||||||
<DropdownContainer>
|
</ModalContent>
|
||||||
<DropdownItem
|
</Modal>
|
||||||
icon="ri-edit-line"
|
|
||||||
data-cy="edit-table"
|
|
||||||
title="Edit"
|
|
||||||
on:click={showEditor}
|
|
||||||
/>
|
|
||||||
<DropdownItem
|
|
||||||
icon="ri-delete-bin-line"
|
|
||||||
title="Delete"
|
|
||||||
on:click={showModal}
|
|
||||||
data-cy="delete-table"
|
|
||||||
/>
|
|
||||||
</DropdownContainer>
|
|
||||||
{/if}
|
|
||||||
</Popover>
|
|
||||||
</div>
|
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
bind:this={confirmDeleteDialog}
|
bind:this={confirmDeleteDialog}
|
||||||
okText="Delete Table"
|
okText="Delete Table"
|
||||||
|
|
Loading…
Reference in New Issue