diff --git a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte
index d239cabd59..f6160e3caa 100644
--- a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte
+++ b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte
@@ -10,6 +10,7 @@
import ManageAccessButton from "./buttons/ManageAccessButton.svelte"
import HideAutocolumnButton from "./buttons/HideAutocolumnButton.svelte"
import { notifications } from "@budibase/bbui"
+ import { ROW_EXPORT_FORMATS } from "constants/backend"
export let view = {}
@@ -19,6 +20,14 @@
let type = "internal"
$: name = view.name
+ $: calculation = view.calculation
+
+ $: supportedFormats = Object.values(ROW_EXPORT_FORMATS).filter(key => {
+ if (calculation && key === ROW_EXPORT_FORMATS.JSON_WITH_SCHEMA) {
+ return false
+ }
+ return true
+ })
// Fetch rows for specified view
$: fetchViewData(name, view.field, view.groupBy, view.calculation)
@@ -68,5 +77,5 @@
{/if}
-
+
diff --git a/packages/builder/src/components/backend/DataTable/buttons/ExportButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/ExportButton.svelte
index fd0d64f6cd..4fa1d07abd 100644
--- a/packages/builder/src/components/backend/DataTable/buttons/ExportButton.svelte
+++ b/packages/builder/src/components/backend/DataTable/buttons/ExportButton.svelte
@@ -7,6 +7,7 @@
export let sorting
export let disabled = false
export let selectedRows
+ export let formats
let modal
@@ -15,5 +16,5 @@
Export
-
+
diff --git a/packages/builder/src/components/backend/DataTable/modals/ExportModal.svelte b/packages/builder/src/components/backend/DataTable/modals/ExportModal.svelte
index ac168698fc..09f76d3522 100644
--- a/packages/builder/src/components/backend/DataTable/modals/ExportModal.svelte
+++ b/packages/builder/src/components/backend/DataTable/modals/ExportModal.svelte
@@ -9,30 +9,43 @@
import download from "downloadjs"
import { API } from "api"
import { Constants, LuceneUtils } from "@budibase/frontend-core"
-
- const FORMATS = [
- {
- name: "CSV",
- key: "csv",
- },
- {
- name: "JSON",
- key: "json",
- },
- {
- name: "JSON with Schema",
- key: "jsonWithSchema",
- },
- ]
+ import { ROW_EXPORT_FORMATS } from "constants/backend"
export let view
export let filters
export let sorting
export let selectedRows = []
+ export let formats
- let exportFormat = FORMATS[0].key
+ const FORMATS = [
+ {
+ name: "CSV",
+ key: ROW_EXPORT_FORMATS.CSV,
+ },
+ {
+ name: "JSON",
+ key: ROW_EXPORT_FORMATS.JSON,
+ },
+ {
+ name: "JSON with Schema",
+ key: ROW_EXPORT_FORMATS.JSON_WITH_SCHEMA,
+ },
+ ]
+
+ $: options = FORMATS.filter(format => {
+ if (formats && !formats.includes(format.key)) {
+ return false
+ }
+ return true
+ })
+
+ let exportFormat
let filterLookup
+ $: if (options && !exportFormat) {
+ exportFormat = Array.isArray(options) ? options[0]?.key : []
+ }
+
$: luceneFilter = LuceneUtils.buildLuceneQuery(filters)
$: exportOpDisplay = buildExportOpDisplay(sorting, filterDisplay, filters)
@@ -190,7 +203,7 @@