diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/DownloadFile.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/DownloadFile.svelte
index 1bd017de79..c8f4ef11f1 100644
--- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/DownloadFile.svelte
+++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/DownloadFile.svelte
@@ -3,14 +3,11 @@
import { onMount } from "svelte"
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
import { FieldType } from "@budibase/types"
+ import { tables, viewsV2 } from "stores/builder"
export let parameters
export let bindings = []
- $: fileBindings = bindings?.filter(
- b => b.fieldSchema?.type === FieldType.ATTACHMENT
- )
-
const fileOptions = [
{
label: "Attachment",
@@ -22,6 +19,26 @@
},
]
+ $: tableOptions = $tables.list.map(table => ({
+ label: table.name,
+ resourceId: table._id,
+ schema: table.schema,
+ }))
+ $: viewOptions = $viewsV2.list.map(view => ({
+ label: view.name,
+ resourceId: view.id,
+ schema: view.schema,
+ }))
+ $: options = [...(tableOptions || []), ...(viewOptions || [])]
+
+ $: selectedTable =
+ parameters.tableId && options.find(t => t.resourceId === parameters.tableId)
+ $: attachmentColumns =
+ selectedTable &&
+ Object.values(selectedTable.schema).filter(
+ c => c.type === FieldType.ATTACHMENT
+ )
+
onMount(() => {
if (!parameters.type) {
parameters.type = "attachment"
@@ -37,13 +54,30 @@
options={fileOptions}
/>
{#if parameters.type === "attachment"}
-
+
+