Merge branch 'master' into allow-public-view-attachment-uploads
This commit is contained in:
commit
51a31e035d
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
const validateDescription = description => {
|
const validateDescription = description => {
|
||||||
if (!description?.length) {
|
if (!description?.length) {
|
||||||
return "Please enter a name"
|
return "Please enter a description"
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
<script>
|
||||||
|
import { Label, Checkbox } from "@budibase/bbui"
|
||||||
|
import DrawerBindableInput from "@/components/common/bindings/DrawerBindableInput.svelte"
|
||||||
|
|
||||||
|
export let parameters
|
||||||
|
export let bindings = []
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="root">
|
||||||
|
<Label>Text to copy</Label>
|
||||||
|
<DrawerBindableInput
|
||||||
|
title="Text to copy"
|
||||||
|
{bindings}
|
||||||
|
value={parameters.textToCopy}
|
||||||
|
on:change={e => (parameters.textToCopy = e.detail)}
|
||||||
|
/>
|
||||||
|
<Label />
|
||||||
|
<Checkbox text="Show notification" bind:value={parameters.showNotification} />
|
||||||
|
{#if parameters.showNotification}
|
||||||
|
<Label>Notification message</Label>
|
||||||
|
<DrawerBindableInput
|
||||||
|
title="Notification message"
|
||||||
|
{bindings}
|
||||||
|
value={parameters.notificationMessage}
|
||||||
|
placeholder="Copied to clipboard"
|
||||||
|
on:change={e => (parameters.notificationMessage = e.detail)}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.root {
|
||||||
|
display: grid;
|
||||||
|
column-gap: var(--spacing-l);
|
||||||
|
row-gap: var(--spacing-s);
|
||||||
|
grid-template-columns: 120px 1fr;
|
||||||
|
align-items: center;
|
||||||
|
max-width: 400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -26,3 +26,4 @@ export { default as CloseModal } from "./CloseModal.svelte"
|
||||||
export { default as ClearRowSelection } from "./ClearRowSelection.svelte"
|
export { default as ClearRowSelection } from "./ClearRowSelection.svelte"
|
||||||
export { default as DownloadFile } from "./DownloadFile.svelte"
|
export { default as DownloadFile } from "./DownloadFile.svelte"
|
||||||
export { default as RowAction } from "./RowAction.svelte"
|
export { default as RowAction } from "./RowAction.svelte"
|
||||||
|
export { default as CopyToClipboard } from "./CopyToClipboard.svelte"
|
||||||
|
|
|
@ -183,6 +183,17 @@
|
||||||
"name": "Row Action",
|
"name": "Row Action",
|
||||||
"type": "data",
|
"type": "data",
|
||||||
"component": "RowAction"
|
"component": "RowAction"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Copy To Clipboard",
|
||||||
|
"type": "data",
|
||||||
|
"component": "CopyToClipboard",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Copied text",
|
||||||
|
"value": "copied"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,6 +421,28 @@ const showNotificationHandler = action => {
|
||||||
|
|
||||||
const promptUserHandler = () => {}
|
const promptUserHandler = () => {}
|
||||||
|
|
||||||
|
const copyToClipboardHandler = async action => {
|
||||||
|
const { textToCopy, showNotification, notificationMessage } =
|
||||||
|
action.parameters
|
||||||
|
|
||||||
|
if (!textToCopy) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(textToCopy)
|
||||||
|
if (showNotification) {
|
||||||
|
const message = notificationMessage || "Copied to clipboard"
|
||||||
|
notificationStore.actions.success(message, true, 3000)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to copy text: ", err)
|
||||||
|
notificationStore.actions.error("Failed to copy to clipboard")
|
||||||
|
}
|
||||||
|
|
||||||
|
return { copied: textToCopy }
|
||||||
|
}
|
||||||
|
|
||||||
const openSidePanelHandler = action => {
|
const openSidePanelHandler = action => {
|
||||||
const { id } = action.parameters
|
const { id } = action.parameters
|
||||||
if (id) {
|
if (id) {
|
||||||
|
@ -514,6 +536,7 @@ const handlerMap = {
|
||||||
["Close Modal"]: closeModalHandler,
|
["Close Modal"]: closeModalHandler,
|
||||||
["Download File"]: downloadFileHandler,
|
["Download File"]: downloadFileHandler,
|
||||||
["Row Action"]: rowActionHandler,
|
["Row Action"]: rowActionHandler,
|
||||||
|
["Copy To Clipboard"]: copyToClipboardHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmTextMap = {
|
const confirmTextMap = {
|
||||||
|
|
Loading…
Reference in New Issue