Add grid menu items to copy row ID and rev

This commit is contained in:
Andrew Kingston 2023-05-10 16:00:12 +01:00
parent c8da2d5717
commit 88c475e4cb
1 changed files with 28 additions and 1 deletions

View File

@ -1,5 +1,11 @@
<script>
import { clickOutside, Menu, MenuItem, notifications } from "@budibase/bbui"
import {
clickOutside,
Menu,
MenuItem,
Helpers,
notifications,
} from "@budibase/bbui"
import { getContext } from "svelte"
const {
@ -36,6 +42,11 @@
$focusedCellId = `${newRow._id}-${column}`
}
}
const copyToClipboard = async value => {
await Helpers.copyToClipboard(value)
notifications.success("Copied to clipboard")
}
</script>
{#if $menu.visible}
@ -64,6 +75,22 @@
>
Edit row in modal
</MenuItem>
<MenuItem
icon="Copy"
disabled={!$focusedRow?._id}
on:click={() => copyToClipboard($focusedRow?._id)}
on:click={menu.actions.close}
>
Copy row _id
</MenuItem>
<MenuItem
icon="Copy"
disabled={!$focusedRow?._rev}
on:click={() => copyToClipboard($focusedRow?._rev)}
on:click={menu.actions.close}
>
Copy row _rev
</MenuItem>
<MenuItem
icon="Duplicate"
disabled={!$config.allowAddRows}