-
-
+
+
+
+
+
{/if}
diff --git a/packages/builder/src/components/userInterface/EventsEditor/EventEditor.svelte b/packages/builder/src/components/userInterface/EventsEditor/EventEditor.svelte
new file mode 100644
index 0000000000..5a94dadc5d
--- /dev/null
+++ b/packages/builder/src/components/userInterface/EventsEditor/EventEditor.svelte
@@ -0,0 +1,200 @@
+
+
+
+
+
+
+
+
+ {#each actionTypes as actionType}
+
+ {actionType.name}
+
+ {/each}
+
+
+
+
+ {#if actions && actions.length > 0}
+ {#each actions as action, index}
+
+
+
+
+ {/each}
+ {/if}
+
+
+ {#if selectedAction}
+
+ {/if}
+
+
+
+
+
Learn more about Actions
+
+
diff --git a/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte b/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte
deleted file mode 100644
index fda964a7ba..0000000000
--- a/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte
+++ /dev/null
@@ -1,176 +0,0 @@
-
-
-
-
-
-
- {#each actionTypes as actionType}
-
- {actionType.name}
-
- {/each}
-
-
-
-
-
- {#if actions && actions.length > 0}
- {#each actions as action, index}
-
-
- {#if action === selectedAction}
-
-
-
- deleteAction(index)}>
- Delete
-
-
-
- {/if}
-
- {/each}
- {/if}
-
-
-
-
Learn more about Actions
-
-
diff --git a/packages/builder/src/components/userInterface/EventsEditor/EventPropertyControl.svelte b/packages/builder/src/components/userInterface/EventsEditor/EventPropertyControl.svelte
index 40a8e77f0c..6d42a25a38 100644
--- a/packages/builder/src/components/userInterface/EventsEditor/EventPropertyControl.svelte
+++ b/packages/builder/src/components/userInterface/EventsEditor/EventPropertyControl.svelte
@@ -2,7 +2,7 @@
import { Button, Modal } from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
import { store } from "builderStore"
- import EventEditorModal from "./EventEditorModal.svelte"
+ import EventEditor from "./EventEditor.svelte"
import BottomDrawer from "components/common/BottomDrawer.svelte"
const dispatch = createEventDispatcher()
@@ -20,7 +20,12 @@
{#if drawerVisible}
-
-
+ (drawerVisible = false)}>
+
+
+
+
+
+
{/if}
diff --git a/packages/builder/src/components/userInterface/TableViewSelect.svelte b/packages/builder/src/components/userInterface/TableViewSelect.svelte
index 423ff390e3..a395497cc4 100644
--- a/packages/builder/src/components/userInterface/TableViewSelect.svelte
+++ b/packages/builder/src/components/userInterface/TableViewSelect.svelte
@@ -2,10 +2,14 @@
import { Button, Icon, DropdownMenu, Spacer, Heading } from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
import { store, backendUiStore, currentAsset } from "builderStore"
+ // import DataBindingDrawer from "components/userInterface/DataBindingDrawer/index.svelte"
+ import BottomDrawer from "components/common/BottomDrawer.svelte"
+ import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte"
import fetchBindableProperties from "../../builderStore/fetchBindableProperties"
const dispatch = createEventDispatcher()
let anchorRight, dropdownRight
+ let bindingDrawerOpen
export let value = {}
@@ -15,14 +19,11 @@
}
function openBindingDrawer() {
- backendUiStore.update(state => {
- state.selectedQueryId = value._id
- return state
- })
- store.update(state => {
- state.bottomDrawerVisible = true
- return state
- })
+ bindingDrawerOpen = true
+ }
+
+ function closeDatabindingDrawer() {
+ bindingDrawerOpen = false
}
$: tables = $backendUiStore.tables.map(m => ({
@@ -47,6 +48,7 @@
name: query.name,
...query,
schema: query.schema,
+ parameters: query.parameters,
type: "query",
}))
@@ -57,6 +59,15 @@
tables: $backendUiStore.tables,
})
+ $: queryBindableProperties = bindableProperties.map(property => ({
+ ...property,
+ category: property.type === "instance" ? "Component" : "Table",
+ label: property.readableBinding,
+ path: property.runtimeBinding,
+ }))
+
+ $: console.log("selected", value)
+
$: links = bindableProperties
.filter(x => x.fieldSchema?.type === "link")
.map(property => {
@@ -78,9 +89,6 @@
{value.label ? value.label : 'Table / View / Query'}
-{#if value.type === "query"}
-
@@ -138,6 +146,25 @@
+{#if value.type === "query"}
+
- {#if $store.bottomDrawerVisible}
-
- {/if}
-
{#if $selectedComponent != null}
diff --git a/packages/client/src/api/datasources.js b/packages/client/src/api/datasources.js
index ef1ff49723..1ea592c94c 100644
--- a/packages/client/src/api/datasources.js
+++ b/packages/client/src/api/datasources.js
@@ -1,8 +1,9 @@
import { fetchTableData } from "./tables"
import { fetchViewData } from "./views"
import { fetchRelationshipData } from "./relationships"
-import { fetchQueryData } from "./queries"
+import { executeQuery } from "./queries"
import { enrichRows } from "./rows"
+import { enrichDataBindings } from "../utils/enrichDataBinding"
/**
* Fetches all rows for a particular Budibase data source.
@@ -20,8 +21,12 @@ export const fetchDatasource = async (datasource, dataContext) => {
} else if (type === "view") {
rows = await fetchViewData(datasource)
} else if (type === "query") {
- // TODO: map to schema
- return await fetchQueryData(datasource)
+ console.log("Query Datasource", datasource)
+ console.log("Data Context", dataContext)
+ // TODO: You left here
+ const parameters = enrichDataBindings(datasource.queryParams, dataContext)
+ console.log("PARSED PARAMS", parameters)
+ return await executeQuery({ _id: datasource._id, parameters })
} else if (type === "link") {
const row = dataContext[datasource.providerId]
rows = await fetchRelationshipData({
diff --git a/packages/client/src/api/queries.js b/packages/client/src/api/queries.js
index 1d1ad5ced7..29ca197d19 100644
--- a/packages/client/src/api/queries.js
+++ b/packages/client/src/api/queries.js
@@ -1,23 +1,13 @@
import API from "./api"
-/**
- * Fetches all rows from a query.
- */
-export const fetchQueryData = async ({ _id }) => {
- const response = await API.get({
- url: `/api/queries/${_id}`,
- })
- return response.rows
-}
-
/**
* Executes a query against an external data connector.
*/
-export const executeQuery = async ({ queryId, params }) => {
+export const executeQuery = async ({ queryId, parameters }) => {
const response = await API.post({
url: `/api/queries/${queryId}`,
body: {
- params,
+ parameters,
},
})
return response.rows
diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js
index c6287bab70..4d0ff98dfb 100644
--- a/packages/client/src/utils/buttonActions.js
+++ b/packages/client/src/utils/buttonActions.js
@@ -28,10 +28,13 @@ const navigationHandler = action => {
const queryExecutionHandler = async (action, context) => {
const { datasourceId, queryId, queryParams } = action.parameters
- // TODO: allow context based bindings for query params
const enrichedQueryParameters = enrichDataBindings(queryParams, context)
- await executeQuery({ datasourceId, queryId, params: enrichedQueryParameters })
+ await executeQuery({
+ datasourceId,
+ queryId,
+ parameters: enrichedQueryParameters,
+ })
}
const handlerMap = {
diff --git a/packages/server/src/api/controllers/query.js b/packages/server/src/api/controllers/query.js
index 2972938528..89c4a5a08b 100644
--- a/packages/server/src/api/controllers/query.js
+++ b/packages/server/src/api/controllers/query.js
@@ -81,7 +81,7 @@ exports.execute = async function(ctx) {
const queryTemplate = handlebars.compile(query.queryString)
// TODO: Take the default params into account
- const parsedQuery = queryTemplate(ctx.request.body.params)
+ const parsedQuery = queryTemplate(ctx.request.body.parameters)
const Integration = integrations[datasource.source]
@@ -94,31 +94,6 @@ exports.execute = async function(ctx) {
ctx.body = response
}
-exports.fetchQuery = async function(ctx) {
- const db = new CouchDB(ctx.user.appId)
-
- const query = await db.get(ctx.params.queryId)
-
- const datasource = await db.get(query.datasourceId)
-
- const Integration = integrations[datasource.source]
-
- if (!Integration) {
- ctx.throw(400, "Integration type does not exist.")
- return
- }
-
- const rows = await new Integration(
- datasource.config,
- query.queryString
- ).query()
-
- ctx.body = {
- schema: query.schema,
- rows,
- }
-}
-
exports.destroy = async function(ctx) {
const db = new CouchDB(ctx.user.appId)
await db.destroy(ctx.params.queryId)
diff --git a/packages/server/src/api/routes/query.js b/packages/server/src/api/routes/query.js
index 06597e52cf..c04bc14fb9 100644
--- a/packages/server/src/api/routes/query.js
+++ b/packages/server/src/api/routes/query.js
@@ -8,10 +8,9 @@ const router = Router()
// TODO: sort out auth so apps have the right permissions
router
.get("/api/queries", authorized(BUILDER), queryController.fetch)
- .get("/api/queries/:queryId", authorized(BUILDER), queryController.fetchQuery)
.post("/api/queries", authorized(BUILDER), queryController.save)
- .post("/api/queries/preview", authorized(BUILDER), queryController.preview)
.post("/api/queries/:queryId", authorized(BUILDER), queryController.execute)
+ .post("/api/queries/preview", authorized(BUILDER), queryController.preview)
.delete("/api/queries/:queryId", authorized(BUILDER), queryController.destroy)
module.exports = router